feat: Delete read receipts on messages deletion (#29720)
parent
fe6f5cdf88
commit
ead7c7bef2
@ -0,0 +1,6 @@ |
||||
--- |
||||
"@rocket.chat/meteor": minor |
||||
"@rocket.chat/model-typings": minor |
||||
--- |
||||
|
||||
Fixed read receipts not getting deleted after corresponding message is deleted |
||||
@ -0,0 +1,13 @@ |
||||
import { ReadReceipts } from '@rocket.chat/models'; |
||||
|
||||
import { callbacks } from '../../../../../lib/callbacks'; |
||||
|
||||
callbacks.add( |
||||
'afterDeleteRoom', |
||||
async (rid) => { |
||||
await ReadReceipts.removeByRoomId(rid); |
||||
return rid; |
||||
}, |
||||
callbacks.priority.LOW, |
||||
'DeleteReadReceipts', |
||||
); |
||||
@ -1,2 +1,3 @@ |
||||
import './afterReadMessages'; |
||||
import './afterSaveMessage'; |
||||
import './afterDeleteRoom'; |
||||
|
||||
@ -1,8 +1,24 @@ |
||||
import type { ReadReceipt } from '@rocket.chat/core-typings'; |
||||
import type { FindCursor } from 'mongodb'; |
||||
import type { ReadReceipt, IUser, IMessage } from '@rocket.chat/core-typings'; |
||||
import type { FindCursor, DeleteResult, UpdateResult, Document, Filter } from 'mongodb'; |
||||
|
||||
import type { IBaseModel } from './IBaseModel'; |
||||
|
||||
export interface IReadReceiptsModel extends IBaseModel<ReadReceipt> { |
||||
findByMessageId(messageId: string): FindCursor<ReadReceipt>; |
||||
removeByUserId(userId: string): Promise<DeleteResult>; |
||||
removeByRoomId(roomId: string): Promise<DeleteResult>; |
||||
removeByRoomIds(roomIds: string[]): Promise<DeleteResult>; |
||||
removeByMessageId(messageId: string): Promise<DeleteResult>; |
||||
removeByMessageIds(messageIds: string[]): Promise<DeleteResult>; |
||||
removeOTRReceiptsUntilDate(roomId: string, until: Date): Promise<DeleteResult>; |
||||
removeByIdPinnedTimestampLimitAndUsers( |
||||
roomId: string, |
||||
ignorePinned: boolean, |
||||
ignoreDiscussion: boolean, |
||||
ts: Filter<IMessage>['ts'], |
||||
users: IUser['_id'][], |
||||
ignoreThreads: boolean, |
||||
): Promise<DeleteResult>; |
||||
setPinnedByMessageId(messageId: string, pinned?: boolean): Promise<Document | UpdateResult>; |
||||
setAsThreadById(messageId: string): Promise<Document | UpdateResult>; |
||||
} |
||||
|
||||
Loading…
Reference in new issue