refactor: 调整创建会话逻辑,创建会话时仅人数大于2人(3人以上会话)才会发送系统提示

pull/64/head
moonrailgun 2 years ago
parent 5c230caef3
commit 0cfa409caf

@ -101,10 +101,11 @@ class ConverseService extends TcService {
}) })
); );
// 发送系统消息, 异步处理 if (participantList.length > 2) {
// 如果创建的是一个多人会话(非双人), 发送系统消息
await Promise.all( await Promise.all(
_.without(participantList, userId).map<Promise<UserStruct>>((memberId) => _.without(participantList, userId).map<Promise<UserStruct>>(
ctx.call('user.getUserInfo', { userId: memberId }) (memberId) => ctx.call('user.getUserInfo', { userId: memberId })
) )
).then((infoList) => { ).then((infoList) => {
return call(ctx).sendSystemMessage( return call(ctx).sendSystemMessage(
@ -114,6 +115,7 @@ class ConverseService extends TcService {
roomId roomId
); );
}); });
}
return await this.transformDocuments(ctx, {}, converse); return await this.transformDocuments(ctx, {}, converse);
} }

Loading…
Cancel
Save