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

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

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

Loading…
Cancel
Save