聊天:获取私聊历史消息
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user