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()