聊天:获取私聊历史消息

This commit is contained in:
liangtongchuan
2021-03-04 21:41:22 +08:00
parent 0bb4caf291
commit ca2d597947
5 changed files with 68 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
import {Application, BackendSession} from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts';
import { createPrivateMsg, pushMsgToRole } from '../../../services/chatService';
import { DEFAULT_MSG_PER_PAGE, STATUS } from '../../../consts';
import { createPrivateMsg, getPrivateMessages, pushMsgToRole } from '../../../services/chatService';
export default function(app: Application) {
@@ -102,7 +102,7 @@ export class ChatHandler {
* @param {{}} msg
* @memberof ChatHandler
*/
async getInitMessage(msg: {}) {
async getInitMessage(msg: {}, session: BackendSession) {
}
@@ -111,8 +111,10 @@ export class ChatHandler {
* @param {{targetRoleId: string, fromSeqId: number, count: number}} msg 聊天对象;聊天消息的顺序 id不传为从最新开始count 为消息条数
* @memberof ChatHandler
*/
async getPrivateMessage(msg: {targetRoleId: string, fromSeqId: number, count: number}) {
async getPrivateMessage(msg: {targetRoleId: string, fromSeqId: number, count: number}, session: BackendSession) {
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, { msgs });
}
}
}