聊天:置顶和删除记录
This commit is contained in:
@@ -337,6 +337,8 @@ export const STATUS = {
|
||||
// 社交相关状态 40000 - 49999
|
||||
SYS_CHANNEL_AUTH_NOT_ENOUGH: { code: 40000, simStr: '无法在系统频道发送消息' },
|
||||
UPDATE_PRIVATE_MSG_READ_TIME_ERR: { code: 40001, simStr: '更新私聊阅读时间失败' },
|
||||
SET_PRIVATE_MSG_TOP_ERR: { code: 40002, simStr: '设置置顶失败' },
|
||||
DEL_PRIVATE_MSG_ERR: { code: 40003, simStr: '删除失败' },
|
||||
// 运营模块相关状态 50000 - 59999
|
||||
ACTIVITY_MISSING: { code: 50000, simStr: '活动丢失' },
|
||||
ACTIVITY_DATA_ERROR: { code: 50001, simStr: '数据错误' },
|
||||
|
||||
@@ -10,6 +10,10 @@ export class PrivateChatRec {
|
||||
lastChatTime: Date; // 最后聊天时间
|
||||
@prop({ required: true, default: 0 })
|
||||
unreadCnt: number; // 未读消息数
|
||||
@prop({ required: true })
|
||||
isTop: boolean; // 是否置顶
|
||||
@prop({ required: true })
|
||||
setTopTime: Date; // 置顶时间
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +65,26 @@ export default class ChatInfo extends BaseModel {
|
||||
.select('-_id').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async setTop(roleId: string, targetRoleId: string, isTop: boolean, time: Date) {
|
||||
const result: ChatInfoType = await ChatInfoModel
|
||||
.findOneAndUpdate(
|
||||
{ roleId, 'recentPrivateChats.targetRoleId': targetRoleId },
|
||||
{ 'recentPrivateChats.$.isTop': isTop, 'recentPrivateChats.$.setTopTime': time },
|
||||
{ new: true })
|
||||
.select('-_id').lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async delMsg(roleId: string, targetRoleId: string) {
|
||||
const result: ChatInfoType = await ChatInfoModel
|
||||
.findOneAndUpdate(
|
||||
{ roleId },
|
||||
{ $pull: { recentPrivateChats: { targetRoleId } } },
|
||||
{ new: true })
|
||||
.select('-_id').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const ChatInfoModel = getModelForClass(ChatInfo);
|
||||
|
||||
Reference in New Issue
Block a user