Add mechanism to locally enforce MSC1763 retention rules (#33772)
* First pass at new retention * Add more test cases * fixup * Fix TODO * Disable retention explicitly from the start * fixup * Just apply retention as-is * Fixup
This commit is contained in:
@@ -441,6 +441,7 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
||||
// can toggle on without reloading and also be accessed immediately after login.
|
||||
cryptoCallbacks: { ...crossSigningCallbacks },
|
||||
enableEncryptedStateEvents: SettingsStore.getValue("feature_msc4362_encrypted_state_events"),
|
||||
unstableMSC1763Retention: SettingsStore.getValue("feature_retention"),
|
||||
roomNameGenerator: (_: string, state: RoomNameState) => {
|
||||
switch (state.type) {
|
||||
case RoomNameType.Generated:
|
||||
|
||||
@@ -1542,6 +1542,11 @@
|
||||
"experimental_section": "Early previews",
|
||||
"extended_profiles_msc_support": "Requires your server to support MSC4133",
|
||||
"feature_disable_call_per_sender_encryption": "Disable per-sender encryption for Element Call",
|
||||
"feature_retention": {
|
||||
"description": "Automatically remove messages from a room when they reach a configured retention period. Currently only supports reading settings.",
|
||||
"disabled_sliding_sync": "Retention cannot be enabled when Sliding Sync is enabled.",
|
||||
"display_name": "Message retention"
|
||||
},
|
||||
"feature_user_status": {
|
||||
"description": "Enables being able to see and set a current status.",
|
||||
"display_name": "User status",
|
||||
|
||||
@@ -225,6 +225,7 @@ export interface Settings {
|
||||
"feature_dynamic_room_predecessors": IFeature;
|
||||
"feature_render_reaction_images": IFeature;
|
||||
"feature_new_room_list": IFeature;
|
||||
"feature_retention": IFeature;
|
||||
"feature_room_list_sections": IFeature;
|
||||
"feature_ask_to_join": IFeature;
|
||||
"feature_notifications": IFeature;
|
||||
@@ -807,6 +808,22 @@ export const SETTINGS: Settings = {
|
||||
),
|
||||
default: false,
|
||||
},
|
||||
"feature_retention": {
|
||||
isFeature: true,
|
||||
labsGroup: LabGroup.Messaging,
|
||||
displayName: _td("labs|feature_retention|display_name"),
|
||||
description: _td("labs|feature_retention|description"),
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG_PRIORITISED,
|
||||
supportedLevelsAreOrdered: true,
|
||||
controller: new IncompatibleController(
|
||||
"feature_sliding_sync",
|
||||
false,
|
||||
true,
|
||||
_td("labs|feature_retention|disabled_sliding_sync"),
|
||||
true,
|
||||
),
|
||||
default: false,
|
||||
},
|
||||
"useCompactLayout": {
|
||||
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
|
||||
displayName: _td("settings|preferences|compact_modern"),
|
||||
|
||||
@@ -10,6 +10,7 @@ import SettingController from "./SettingController";
|
||||
import { type SettingLevel } from "../SettingLevel";
|
||||
import SettingsStore from "../SettingsStore";
|
||||
import { type BooleanSettingKey } from "../Settings.tsx";
|
||||
import PlatformPeg from "../../PlatformPeg.ts";
|
||||
|
||||
/**
|
||||
* Enforces that a boolean setting cannot be enabled if the incompatible setting
|
||||
@@ -21,6 +22,8 @@ export default class IncompatibleController extends SettingController {
|
||||
private settingName: BooleanSettingKey,
|
||||
private forcedValue: any = false,
|
||||
private incompatibleValue: any | ((v: any) => boolean) = true,
|
||||
private readonly disabledMessage?: string,
|
||||
private readonly forceReload = false,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -37,8 +40,11 @@ export default class IncompatibleController extends SettingController {
|
||||
return null; // no override
|
||||
}
|
||||
|
||||
public get settingDisabled(): boolean {
|
||||
return this.incompatibleSetting;
|
||||
public get settingDisabled(): boolean | string {
|
||||
if (this.incompatibleSetting) {
|
||||
return this.disabledMessage ?? true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public get incompatibleSetting(): boolean {
|
||||
@@ -47,4 +53,10 @@ export default class IncompatibleController extends SettingController {
|
||||
}
|
||||
return SettingsStore.getValue(this.settingName) === this.incompatibleValue;
|
||||
}
|
||||
|
||||
public onChange(): void {
|
||||
if (this.forceReload) {
|
||||
PlatformPeg.get()?.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user