Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/pushprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [
],
actions: [],
},
];

const DEFAULT_UNDERRIDE_RULES: IPushRule[] = [
{
// For homeservers which don't support MSC3914 yet
rule_id: ".org.matrix.msc3914.rule.room.call",
Expand Down Expand Up @@ -163,6 +166,7 @@ export class PushProcessor {
if (!newRules) newRules = {} as IPushRules;
if (!newRules.global) newRules.global = {} as PushRuleSet;
if (!newRules.global.override) newRules.global.override = [];
if (!newRules.global.override) newRules.global.underride = [];

// Merge the client-level defaults with the ones from the server
const globalOverrides = newRules.global.override;
Expand All @@ -183,6 +187,24 @@ export class PushProcessor {
}
}

const globalUnderrides = newRules.global.underride ?? [];
for (const underride of DEFAULT_UNDERRIDE_RULES) {
const existingRule = globalUnderrides
.find((r) => r.rule_id === underride.rule_id);

if (existingRule) {
// Copy over the actions, default, and conditions. Don't touch the user's preference.
existingRule.default = underride.default;
existingRule.conditions = underride.conditions;
existingRule.actions = underride.actions;
} else {
// Add the rule
const ruleId = underride.rule_id;
logger.warn(`Adding default global underride for ${ruleId}`);
globalUnderrides.push(underride);
}
}

return newRules;
}

Expand Down