diff --git a/.changeset/weak-turkeys-sit.md b/.changeset/weak-turkeys-sit.md new file mode 100644 index 0000000000000..c4673b9d049df --- /dev/null +++ b/.changeset/weak-turkeys-sit.md @@ -0,0 +1,8 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixed a bad behavior with the interaction between OTR system messages & trash collection. We use trash collection as a temporary storage that holds recently deleted items from some collections. Messages is one of those. This was causing "User joined OTR" messages to be viewable when querying the trash collection. +Since OTR messages are by definition private, code was updated to bypass trash collection when removing these special messages. + +Note: this only applies to these system messages. OTR user's messages are not stored on the database. diff --git a/apps/meteor/ee/server/models/raw/ReadReceipts.ts b/apps/meteor/ee/server/models/raw/ReadReceipts.ts index f3a08d4de8cab..cf0dd7283f318 100644 --- a/apps/meteor/ee/server/models/raw/ReadReceipts.ts +++ b/apps/meteor/ee/server/models/raw/ReadReceipts.ts @@ -51,7 +51,7 @@ export class ReadReceiptsRaw extends BaseRaw implements IReadReceip }, ts: { $lte: until }, }; - return this.deleteMany(query); + return this.col.deleteMany(query); } async removeByIdPinnedTimestampLimitAndUsers( diff --git a/apps/meteor/server/models/raw/Messages.ts b/apps/meteor/server/models/raw/Messages.ts index 0bd25dca4620d..9f9ff7882d325 100644 --- a/apps/meteor/server/models/raw/Messages.ts +++ b/apps/meteor/server/models/raw/Messages.ts @@ -673,7 +673,7 @@ export class MessagesRaw extends BaseRaw implements IMessagesModel { }, ts: { $lte: ts }, }; - return this.deleteMany(query); + return this.col.deleteMany(query); } addTranslations(messageId: string, translations: Record, providerName: string): Promise {