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

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

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

Loading…
Cancel
Save