Skip to content

Commit

Permalink
fix: Discussion messages deleted despite the "Do not delete discussio…
Browse files Browse the repository at this point in the history
…n messages" retention policy enabled (#31113)
  • Loading branch information
heitortanoue authored Dec 4, 2023
1 parent 5224eab commit 92ee9fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-ducks-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Discussion messages deleted despite the "Do not delete discussion messages" retention policy enabled
4 changes: 4 additions & 0 deletions apps/meteor/app/retention-policy/server/cronPruneMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ async function job(): Promise<void> {
const ignoreDiscussion = settings.get<boolean>('RetentionPolicy_DoNotPruneDiscussion');
const ignoreThreads = settings.get<boolean>('RetentionPolicy_DoNotPruneThreads');

const ignoreDiscussionQuery = ignoreDiscussion ? { prid: { $exists: false } } : {};

// get all rooms with default values
for await (const type of types) {
const maxAge = maxTimes[type] || 0;
Expand All @@ -34,6 +36,7 @@ async function job(): Promise<void> {
't': type,
'$or': [{ 'retention.enabled': { $eq: true } }, { 'retention.enabled': { $exists: false } }],
'retention.overrideGlobal': { $ne: true },
...ignoreDiscussionQuery,
},
{ projection: { _id: 1 } },
).toArray();
Expand All @@ -56,6 +59,7 @@ async function job(): Promise<void> {
'retention.enabled': { $eq: true },
'retention.overrideGlobal': { $eq: true },
'retention.maxAge': { $gte: 0 },
...ignoreDiscussionQuery,
},
{ projection: { _id: 1, retention: 1 } },
).toArray();
Expand Down

0 comments on commit 92ee9fa

Please sign in to comment.