好友:拉黑对方聊天也屏蔽

This commit is contained in:
luying
2022-06-13 16:55:58 +08:00
parent 68e5d11230
commit 106fb3ce39
6 changed files with 39 additions and 16 deletions
+8 -3
View File
@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { MSG_STATUS } from '../consts';
/**
* 私聊信息
@@ -48,19 +49,23 @@ export default class PrivateMessage extends BaseModel {
}
public static async getMsgs(roomId: string, fromSeqId: number, count: number) {
const result = await PrivateMessageModel.find({ roomId, seqId: { $lt: fromSeqId } }).sort({ seqId: -1 }).limit(count).lean();
const result = await PrivateMessageModel.find({ roomId, seqId: { $lt: fromSeqId }, status: MSG_STATUS.NORMAL }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
public static async getMsgsByTime(roomId: string, time: Date, count: number) {
const result = await PrivateMessageModel.find({ roomId, createdAt: { $gt: time } }).sort({ seqId: -1 }).limit(count).lean();
const result = await PrivateMessageModel.find({ roomId, createdAt: { $gt: time }, status: MSG_STATUS.NORMAL }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
public static async getMsgByRooms(roomIds: string[], count: number) {
const result = await PrivateMessageModel.find({ roomId: { $in: roomIds } }).sort({ seqId: -1 }).limit(count).lean();
const result = await PrivateMessageModel.find({ roomId: { $in: roomIds }, status: MSG_STATUS.NORMAL }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
public static async blockMsg(roomId: string) {
await PrivateMessageModel.updateMany({ roomId }, { $set: { status: MSG_STATUS.BLOCKED } });
}
}