add login state at preview

This commit is contained in:
2024-06-23 12:56:08 +07:00
parent d4c149d5a2
commit 6f864d1d7a
2 changed files with 15 additions and 5 deletions

View File

@ -38,7 +38,7 @@ class ChuniBase:
self.logger.warn(
"User ID %d attempted to log in while having a profile lock expiring on %s.",
user_id, lock_result["expires_at"],
extra=lock_result["extra"]
extra=lock_result["extra"] or {}
)
return {"returnCode": 0}
@ -669,9 +669,12 @@ class ChuniBase:
return bytes([ord(c) for c in src]).decode("utf-8")
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
profile = await self.data.profile.get_profile_preview(data["userId"], self.version)
user_id = int(data["userId"])
profile = await self.data.profile.get_profile_preview(user_id, self.version)
if profile is None:
return None
profile_character = await self.data.item.get_character(
data["userId"], profile["characterId"]
)
@ -683,10 +686,12 @@ class ChuniBase:
chara.pop("id")
chara.pop("user")
lock_result = await self.data.user.check_lock_for_game(user_id, self.game)
return {
"userId": data["userId"],
# Current Login State
"isLogin": False,
"isLogin": lock_result is not None,
"lastLoginDate": profile["lastPlayDate"],
# User Profile
"userName": profile["userName"],

View File

@ -152,9 +152,12 @@ class ChuniNew(ChuniBase):
return {"userId": data["userId"], "symbolCharInfoList": []}
async def handle_get_user_preview_api_request(self, data: Dict) -> Dict:
profile = await self.data.profile.get_profile_preview(data["userId"], self.version)
user_id = int(data["userId"])
profile = await self.data.profile.get_profile_preview(user_id, self.version)
if profile is None:
return None
profile_character = await self.data.item.get_character(
data["userId"], profile["characterId"]
)
@ -165,11 +168,13 @@ class ChuniNew(ChuniBase):
chara = profile_character._asdict()
chara.pop("id")
chara.pop("user")
lock_result = await self.data.user.check_lock_for_game(user_id, self.game)
data1 = {
"userId": data["userId"],
# Current Login State
"isLogin": False,
"isLogin": lock_result is not None,
"lastLoginDate": profile["lastPlayDate"],
# User Profile
"userName": profile["userName"],