好友:拉黑对方聊天也屏蔽
This commit is contained in:
@@ -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 } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user