diff --git a/ts/RemoteConfig.ts b/ts/RemoteConfig.ts index 01db26a505fa..08eb8944a6a5 100644 --- a/ts/RemoteConfig.ts +++ b/ts/RemoteConfig.ts @@ -14,6 +14,7 @@ export type ConfigKeyType = | 'desktop.groupCalling' | 'desktop.gv2' | 'desktop.internalUser' + | 'desktop.messageCleanup' | 'desktop.mandatoryProfileSharing' | 'desktop.mediaQuality.levels' | 'desktop.messageRequests' diff --git a/ts/util/MessageController.ts b/ts/util/MessageController.ts index 8d66502cedce..e67e99f39339 100644 --- a/ts/util/MessageController.ts +++ b/ts/util/MessageController.ts @@ -6,6 +6,7 @@ import * as durations from './durations'; import { map, filter } from './iterables'; import { isNotNil } from './isNotNil'; import type { MessageAttributesType } from '../model-types.d'; +import { isEnabled } from '../RemoteConfig'; const FIVE_MINUTES = 5 * durations.MINUTE; @@ -125,6 +126,9 @@ export class MessageController { } startCleanupInterval(): NodeJS.Timeout | number { - return setInterval(this.cleanup.bind(this), durations.HOUR); + return setInterval( + this.cleanup.bind(this), + isEnabled('desktop.messageCleanup') ? FIVE_MINUTES : durations.HOUR + ); } }