fix i18n middleware
All checks were successful
Build Docs / changes (push) Successful in 5s
Build Docs / build-docs (push) Has been skipped
Build Docs / deploy-docs (push) Has been skipped

This commit is contained in:
Alexander Kalinovsky
2025-04-27 18:15:57 +07:00
parent 5343e5b2cf
commit a4999159b9

View File

@@ -17,7 +17,7 @@ class I18nMiddleware(SimpleI18nMiddleware):
async def get_locale(self, event: TelegramObject, data: Dict[str, Any]) -> str: async def get_locale(self, event: TelegramObject, data: Dict[str, Any]) -> str:
db_session = data.get("db_session") db_session = data.get("db_session")
if db_session and event.model_fields.get("from_user"): if db_session and event.__dict__.get("from_user"):
user = await self.user_class.get(id=event.from_user.id, session=db_session) user = await self.user_class.get(id=event.from_user.id, session=db_session)
if user and user.lang: if user and user.lang:
return user.lang.value return user.lang.value