聊天:部分配置读表

This commit is contained in:
liangtongchuan
2021-03-23 12:22:41 +08:00
parent 3dbd9ba7bf
commit 470be1a72f
8 changed files with 68 additions and 82 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
import { CHAT_SYSTEM } from './../pubUtils/dicParam';
import { PrivateChatRec } from './../db/ChatInfo';
import { RoleModel, RoleUpdate } from './../db/Role';
import { RoleModel } from './../db/Role';
import { GroupMessageModel } from './../db/GroupMessage';
import { CounterModel } from './../db/Counter';
import { STATUS } from './../consts/statusCode';
@@ -7,7 +8,7 @@ import { PrivateMessageModel, PrivateMessageParam, PrivateMessageType } from './
import { GroupMessageParam, GroupMessageType } from '../db/GroupMessage';
import { genCode, resResult } from '../pubUtils/util';
import { pinus } from 'pinus';
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_PRIVATE_MSG_ROUTE, RECENT_PRIVATE_CHATS_CNT, RECENT_GROUP_MSGS_CNT, MSG_TYPE, MSG_SOURCE } from '../consts';
import { CHANNEL_PREFIX, MSG_CODE_LEN, MSG_STATUS, ON_PRIVATE_MSG_ROUTE, MSG_TYPE, MSG_SOURCE } from '../consts';
import { getRoleOnlineInfo } from './redisService';
import { ChatInfoModel } from '../db/ChatInfo';
import { channelServer } from './chatChannelService';
@@ -172,7 +173,7 @@ function sendFromRole(msg: GroupMessageParam) {
* @returns
*/
async function recentGroupMsgs(roomId: string, count?: number) {
const msgs = await GroupMessageModel.getMsgs(roomId, Infinity, count || RECENT_GROUP_MSGS_CNT);
const msgs = await GroupMessageModel.getMsgs(roomId, Infinity, count || CHAT_SYSTEM.RECENT_GROUP_MSGS_CNT);
const roleIds = msgs
.map(msg => { return sendFromRole(msg) ? msg.roleId : null })
.filter(roleId => !!roleId);
@@ -281,7 +282,7 @@ export async function recentPrivateChatInfos(roleId: string, roleName: string) {
const { recentPrivateChats } = await roleChatInfos(roleId, roleName);
recentPrivateChats
.sort((a, b) => a.lastChatTime.getTime() - b.lastChatTime.getTime())
.splice(RECENT_PRIVATE_CHATS_CNT);
.splice(CHAT_SYSTEM.RECENT_PRIVATE_CHATS_CNT);
if (!recentPrivateChats || !recentPrivateChats.length) return null;
const roleInfos = await RoleModel.findRoleByField('roleId', recentPrivateChats.map(chat => { return chat.targetRoleId }));