聊天:查看私聊消息的接口和测试

This commit is contained in:
liangtongchuan
2021-03-11 10:24:10 +08:00
parent 9a2c536288
commit cce6a5af5e
5 changed files with 55 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import { CHANNEL_PREFIX, MSG_SOURCE } from './../../../consts/constModules/chatC
import {Application, BackendSession} from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { DEFAULT_MSG_PER_PAGE, STATUS } from '../../../consts';
import { createGroupMsg, createPrivateMsg, getPrivateMessages, groupRoomId, pushGroupMsgToRoom, pushMsgToRole } from '../../../services/chatService';
import { createGroupMsg, createPrivateMsg, getPrivateMessages, groupRoomId, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadTime } from '../../../services/chatService';
export default function(app: Application) {
@@ -125,4 +125,21 @@ export class ChatHandler {
const msgs = await getPrivateMessages(roleId, targetRoleId, fromSeqId, count);
return resResult(STATUS.SUCCESS, { msgs });
}
/**
* @description 查看私聊,主要用于更新最后查看时间和未读消息数
* @param {{ targetRoleId: string }} msg
* @param {BackendSession} session
* @returns
* @memberof ChatHandler
*/
async readPrivateMessage(msg: { targetRoleId: string }, session: BackendSession) {
const roleId = session.get('roleId');
const { targetRoleId } = msg;
const result = await updatePrivateMsgReadTime(roleId, targetRoleId);
if (!result) {
return resResult(STATUS.UPDATE_PRIVATE_MSG_READ_TIME_ERR);
}
return resResult(STATUS.SUCCESS, result);
}
}