feat(admin): allow to delete private message

pull/147/merge
moonrailgun 1 year ago
parent d7e8a9d592
commit 915ed01a51

@ -345,11 +345,16 @@ class MessageService extends TcService {
throw new DataNotFoundError(t('该消息未找到'));
}
const converseId = String(message.converseId);
const groupId = message.groupId;
if (!groupId) {
// 私人会话
if (userId !== SYSTEM_USERID) {
// 如果是私人发起的, 则直接抛出异常
throw new Error(t('无法删除私人信息'));
}
} else {
// 群组会话, 进行权限校验
const [hasPermission] = await call(ctx).checkUserPermissions(
String(groupId),
userId,
@ -359,8 +364,8 @@ class MessageService extends TcService {
if (!hasPermission) {
throw new NoPermissionError(t('没有删除权限')); // 仅管理员允许删除
}
}
const converseId = String(message.converseId);
await this.adapter.removeById(messageId); // TODO: 考虑是否要改为软删除
this.roomcastNotify(ctx, converseId, 'delete', { converseId, messageId });

Loading…
Cancel
Save