From 8a2e619d855838979d30dec048f51e6125239e88 Mon Sep 17 00:00:00 2001 From: Douglas Fabris Date: Fri, 16 Aug 2024 21:59:29 -0300 Subject: [PATCH] fix: Missing retention's `ignoreThreads` param for old channels (#33028) --- .changeset/gold-knives-sparkle.md | 5 +++++ .../meteor/server/startup/migrations/index.ts | 1 + apps/meteor/server/startup/migrations/v306.ts | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 .changeset/gold-knives-sparkle.md create mode 100644 apps/meteor/server/startup/migrations/v306.ts diff --git a/.changeset/gold-knives-sparkle.md b/.changeset/gold-knives-sparkle.md new file mode 100644 index 000000000000..144573944d49 --- /dev/null +++ b/.changeset/gold-knives-sparkle.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes an issue where ignore threads parameter were not being affected by retention policy overriding in old channels diff --git a/apps/meteor/server/startup/migrations/index.ts b/apps/meteor/server/startup/migrations/index.ts index e7a18e836722..e7efdc89ebde 100644 --- a/apps/meteor/server/startup/migrations/index.ts +++ b/apps/meteor/server/startup/migrations/index.ts @@ -38,5 +38,6 @@ import './v301'; import './v303'; import './v304'; import './v305'; +import './v306'; export * from './xrun'; diff --git a/apps/meteor/server/startup/migrations/v306.ts b/apps/meteor/server/startup/migrations/v306.ts new file mode 100644 index 000000000000..fcd6ae9e3558 --- /dev/null +++ b/apps/meteor/server/startup/migrations/v306.ts @@ -0,0 +1,22 @@ +import { Rooms } from '@rocket.chat/models'; + +import { addMigration } from '../../lib/migrations'; + +addMigration({ + version: 306, + name: 'Adds missing ignoreThreads parameter for old rooms with retention policy overridden', + async up() { + await Rooms.updateMany( + { + 'retention.enabled': true, + 'retention.overrideGlobal': true, + 'retention.ignoreThreads': { $exists: false }, + }, + { + $set: { + 'retention.ignoreThreads': false, + }, + }, + ); + }, +});