From 93658a0aa35eec37661707e00e23a661c8a6d4f2 Mon Sep 17 00:00:00 2001 From: urec56 Date: Tue, 20 Aug 2024 14:47:27 +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/dao/chat.py | 2 +- app/services/chat_service.py | 3 ++- app/utils/unit_of_work.py | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/dao/chat.py b/app/dao/chat.py index 8f1d839..cd24531 100644 --- a/app/dao/chat.py +++ b/app/dao/chat.py @@ -58,7 +58,7 @@ class ChatDAO(BaseDAO): stmt = insert(UserChat).values(user_id=user_id, chat_id=chat_id) await self.session.execute(stmt) except IntegrityError: - pass + raise UserAlreadyInChatException async def change_data(self, chat_id: int, chat_name: str, avatar_image: HttpUrl) -> None: stmt = ( diff --git a/app/services/chat_service.py b/app/services/chat_service.py index 2010c9f..53ef656 100644 --- a/app/services/chat_service.py +++ b/app/services/chat_service.py @@ -51,7 +51,8 @@ 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) + if user_id != settings.ADMIN_USER_ID: + await uow.chat.add_user_to_chat(settings.ADMIN_USER_ID, chat_id) async with RedisService(is_raise=True) as redis: await redis.delete_key(key=f"user_allowed_chats: {user_id}") await uow.commit() diff --git a/app/utils/unit_of_work.py b/app/utils/unit_of_work.py index a1da689..4d2a5ad 100644 --- a/app/utils/unit_of_work.py +++ b/app/utils/unit_of_work.py @@ -24,10 +24,9 @@ class UnitOfWork: await self.rollback() await self.session.close() except SQLAlchemyError: - pass - # raise BlackPhoenixException - # if isinstance(exc, SQLAlchemyError): - # raise BlackPhoenixException + raise BlackPhoenixException + if isinstance(exc, SQLAlchemyError): + raise BlackPhoenixException async def commit(self): await self.session.commit()