fix(chat): 修复多个聊天错误 消息格式错误导致断连、新消息会通知到发件人、加强消息发送的成员验证
This commit is contained in:
@@ -14,6 +14,7 @@ from core.db.models import ReadStatus, User, Chat, Message
|
||||
|
||||
from .managers import SocketManager
|
||||
from . import schema
|
||||
from .services import get_chat
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
socket_manager = SocketManager()
|
||||
@@ -28,7 +29,8 @@ async def send_new_message(
|
||||
incoming_message: schema.WSMessage,
|
||||
):
|
||||
chat_guid: str = str(incoming_message.chat_guid)
|
||||
chat: Chat | None = await CRUD(db_session, Chat).get(filters={'guid': chat_guid})
|
||||
# chat: Chat | None = await CRUD(db_session, Chat).get(filters={'guid': chat_guid, 'is_deleted': False}
|
||||
chat: Chat | None = await get_chat(chat_guid, current_user, db_session)
|
||||
|
||||
# 判断是否为新聊天
|
||||
if not chats or chat_guid not in chats:
|
||||
@@ -56,8 +58,6 @@ async def send_new_message(
|
||||
|
||||
await db_session.flush()
|
||||
await db_session.commit()
|
||||
# await db_session.refresh(message, attribute_names=["user", "chat"])
|
||||
# await db_session.refresh(chat, attribute_names=["users"])
|
||||
|
||||
except Exception as exc_info:
|
||||
await db_session.rollback()
|
||||
|
||||
Reference in New Issue
Block a user