From 43ae5b9346f576fb234402aee17c0586b189c3a2 Mon Sep 17 00:00:00 2001 From: urec56 Date: Tue, 20 Aug 2024 14:28:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B0=D0=B3=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/chat_service.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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()