聊天:增加用户信息等字段

This commit is contained in:
liangtongchuan
2021-03-17 18:05:48 +08:00
parent 76aee57e67
commit 94ca8614b4
5 changed files with 43 additions and 8 deletions
@@ -3,6 +3,7 @@ import {Application, BackendSession} from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { DEFAULT_MSG_PER_PAGE, STATUS } from '../../../consts';
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo } from '../../../services/chatService';
import { getSimpleRoleInfo } from '../../../services/roleService';
export default function(app: Application) {
@@ -129,7 +130,8 @@ export class ChatHandler {
const roleId = session.get('roleId');
const { targetRoleId, fromSeqId = Infinity, count = DEFAULT_MSG_PER_PAGE } = msg;
const msgs = await getPrivateMessages(roleId, targetRoleId, fromSeqId, count);
return resResult(STATUS.SUCCESS, { targetRoleId, msgs });
const targetRoleInfo = await getSimpleRoleInfo(targetRoleId);
return resResult(STATUS.SUCCESS, { targetRoleId, msgs, targetRoleInfo });
}
/**
@@ -3,7 +3,7 @@ import { Application, ChannelService } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { ON_ADD_CHANNEL_ROUTE, ON_GROUP_MSG_ROUTE, ON_LEAVE_CHANNEL_ROUTE, STATUS } from '../../../consts';
import { PrivateMessageType } from '../../../db/PrivateMessage';
import { addUserToChannel } from '../../../services/roleService';
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
import { ChannelUser } from '../../../domain/ChannelUser';
export default function (app: Application) {
@@ -151,7 +151,8 @@ export class ChatRemote {
public async sendGroupMsg(roomId: string, msg: Partial<GroupMessageType>) {
let channel = this.channelService.getChannel(roomId, false);
if (!channel) return;
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, msg));
const roleInfo = await getSimpleRoleInfo(msg.roleId);
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msg, roleInfo }));
}
/**