Skip to content

Commit

Permalink
Merge pull request #559 from Studio-Yandex-Practicum/add/user_status_…
Browse files Browse the repository at this point in the history
…check_in_decorated_handler

Добавить проверку статуса модерации при использовании кнопок в истории чата
  • Loading branch information
gorskyolga authored Aug 30, 2024
2 parents 3518cac + 92e7cb3 commit f860987
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from src.bot.keyboards import get_unregistered_user_keyboard
from src.bot.services import ExternalSiteUserService
from src.core.depends import Container
from src.core.enums import UserRoles
from src.core.enums import UserRoles, UserStatus

ReturnType = TypeVar("ReturnType")
ParameterTypes = ParamSpec("ParameterTypes")
Expand Down Expand Up @@ -64,7 +64,11 @@ async def decorated_handler(
if id_hash
else await ext_site_user_service.get_by_telegram_id(telegram_user.id)
)
if ext_site_user and ext_site_user.role in list(UserRoles):
if (
ext_site_user
and ext_site_user.role in set(UserRoles)
and ext_site_user.moderation_status in set(UserStatus)
):
await handler(update, context, ext_site_user, *args, **kwargs)
else:
keyboard = await get_unregistered_user_keyboard()
Expand Down

0 comments on commit f860987

Please sign in to comment.