From eea6f5d9d735132f8bcc897dc2d9c8ec7f1e5377 Mon Sep 17 00:00:00 2001 From: linju Date: Mon, 11 Nov 2024 20:34:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=BB=99=E8=87=AA=E5=B7=B1=E5=8F=91=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E5=88=9B=E5=BB=BA=E4=B8=A4=E6=9D=A1=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E8=AE=B0=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uniCloud/cloudfunctions/uni-im-co/msg.js | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/uniCloud/cloudfunctions/uni-im-co/msg.js b/uniCloud/cloudfunctions/uni-im-co/msg.js index bcc873b..9a461c2 100644 --- a/uniCloud/cloudfunctions/uni-im-co/msg.js +++ b/uniCloud/cloudfunctions/uni-im-co/msg.js @@ -459,11 +459,6 @@ async function _createOrUpdateConversation(conversation_id, msgData, chat_source } const clientInfo = this.getClientInfo() if( conversation_grade === 300 && msgData.to_uid && clientInfo.source != 'function' && this.current_uid != 'system'){ - // console.error('createOrUpdateConversation conversation_grade 300~~~~~',clientInfo.appVersionCode); - // TODO:用于向下兼容 - if (clientInfo.appVersionCode < 24042501) { - throw new Error('你的客户端版本过旧,不能发起新会话。请刷新后重试') - } // 仅限:系统管理员参与的 或 群成员向群管理员 发起私聊 let check = false // 消息发送者是系统管理员 @@ -547,22 +542,26 @@ async function _createOrUpdateConversation(conversation_id, msgData, chat_source let {data:[groupInfo]} = await db.collection('uni-im-group') .doc(msgData.group_id) .field({ - type: true, + type: true }) .get() senderConversation.group_type = groupInfo?.type // 群聊只为当前用户创建会话 await dbUniImConversation.add(senderConversation) } else { - // 2.消息接收者 会话数据 - receiverConversation = { - ...senderConversation, - unread_count: 1, - user_id: msgData.to_uid, - friend_uid: msgData.from_uid + const newConversation = [senderConversation] + // 如果不是:用户自己给自己发消息 + if (msgData.to_uid != msgData.from_uid) { + // 2.消息接收者 会话数据 + receiverConversation = { + ...senderConversation, + unread_count: 1, + user_id: msgData.to_uid, + friend_uid: msgData.from_uid + } + newConversation.push(receiverConversation) } - // 单聊,同时为收发双方创建此会话 - await dbUniImConversation.add([senderConversation, receiverConversation]) + await dbUniImConversation.add(newConversation) } } else { // 会话已存在,更新相关内容 -- GitLab