🐛 Fix refresh cookies when user request

This commit is contained in:
xtaodada 2023-11-10 15:32:20 +08:00
parent e146ca5c16
commit e356549419
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -255,11 +255,6 @@ class GenshinHelper(Plugin):
) as client:
try:
yield client
except SimnetBadRequest as exc:
if exc.ret_code == 1034 and devices is not None:
devices.is_valid = False
await self.devices_service.update(devices)
raise exc
except InvalidCookies as exc:
refresh = False
cookie_model.status = CookiesStatusEnum.INVALID_COOKIES
@ -299,6 +294,11 @@ class GenshinHelper(Plugin):
if refresh:
raise CookieException(message="The cookie has been refreshed.") from exc
raise exc
except SimnetBadRequest as exc:
if exc.ret_code == 1034 and devices is not None:
devices.is_valid = False
await self.devices_service.update(devices)
raise exc
async def get_genshin_client(self, user_id: int, region: Optional[RegionEnum] = None) -> GenshinClient:
player = await self.players_service.get_player(user_id, region)