diff --git a/app/services/chat_service.py b/app/services/chat_service.py index 9a45d80..5fc3b6b 100644 --- a/app/services/chat_service.py +++ b/app/services/chat_service.py @@ -3,7 +3,8 @@ from urllib.parse import urljoin from pydantic import ValidationError -from app.chat.exceptions import UserDontHavePermissionException, UserCanNotReadThisChatException +from app.chat.exceptions import UserDontHavePermissionException, UserCanNotReadThisChatException, \ + UserAlreadyInChatException from app.chat.shemas import SAllowedChats, SChangeData, SPinnedChats, SChat from app.config import settings from app.services.redis_service import RedisService @@ -50,7 +51,10 @@ class ChatService: avatar_image=user_chat_for.avatar_image ) await uow.chat.add_user_to_chat(user_id, chat_id) - await uow.chat.add_user_to_chat(settings.ADMIN_USER_ID, chat_id) + try: + await uow.chat.add_user_to_chat(settings.ADMIN_USER_ID, chat_id) + except UserAlreadyInChatException: + pass async with RedisService(is_raise=True) as redis: await redis.delete_key(key=f"user_allowed_chats: {user_id}") await uow.commit()