Skip to content
Snippets Groups Projects
Unverified Commit c2d7216c authored by dionisio-bot[bot]'s avatar dionisio-bot[bot] Committed by GitHub
Browse files

fix: Retention Policy cached settings not updated during upgrade procedure (#33265)

parent ed7398d9
Branches release-6.12.1
No related tags found
No related merge requests found
---
"@rocket.chat/meteor": patch
---
fixed retention policy max age settings not being respected after upgrade
......@@ -2,6 +2,7 @@ import { Settings } from '@rocket.chat/models';
import type { UpdateResult } from 'mongodb';
import { upsertPermissions } from '../../../app/authorization/server/functions/upsertPermissions';
import { settings } from '../../../app/settings/server';
import { migrateDatabase, onServerVersionChange } from '../../lib/migrations';
import { ensureCloudWorkspaceRegistered } from '../cloudRegistration';
......@@ -23,10 +24,13 @@ const moveRetentionSetting = async () => {
{ _id: { $in: Array.from(maxAgeSettingMap.keys()) }, value: { $ne: -1 } },
{ projection: { _id: 1, value: 1 } },
).forEach(({ _id, value }) => {
if (!maxAgeSettingMap.has(_id)) {
const newSettingId = maxAgeSettingMap.get(_id);
if (!newSettingId) {
throw new Error(`moveRetentionSetting - Setting ${_id} equivalent does not exist`);
}
const newValue = convertDaysToMs(Number(value));
promises.push(
Settings.updateOne(
{
......@@ -34,11 +38,17 @@ const moveRetentionSetting = async () => {
},
{
$set: {
value: convertDaysToMs(Number(value)),
value: newValue,
},
},
),
);
const currentCache = settings.getSetting(newSettingId);
if (!currentCache) {
return;
}
settings.set({ ...currentCache, value: newValue });
});
await Promise.all(promises);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment