@@ -93,6 +93,9 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [
93
93
] ,
94
94
actions : [ ] ,
95
95
} ,
96
+ ] ;
97
+
98
+ const DEFAULT_UNDERRIDE_RULES : IPushRule [ ] = [
96
99
{
97
100
// For homeservers which don't support MSC3914 yet
98
101
rule_id : ".org.matrix.msc3914.rule.room.call" ,
@@ -163,6 +166,7 @@ export class PushProcessor {
163
166
if ( ! newRules ) newRules = { } as IPushRules ;
164
167
if ( ! newRules . global ) newRules . global = { } as PushRuleSet ;
165
168
if ( ! newRules . global . override ) newRules . global . override = [ ] ;
169
+ if ( ! newRules . global . override ) newRules . global . underride = [ ] ;
166
170
167
171
// Merge the client-level defaults with the ones from the server
168
172
const globalOverrides = newRules . global . override ;
@@ -183,6 +187,24 @@ export class PushProcessor {
183
187
}
184
188
}
185
189
190
+ const globalUnderrides = newRules . global . underride ?? [ ] ;
191
+ for ( const underride of DEFAULT_UNDERRIDE_RULES ) {
192
+ const existingRule = globalUnderrides
193
+ . find ( ( r ) => r . rule_id === underride . rule_id ) ;
194
+
195
+ if ( existingRule ) {
196
+ // Copy over the actions, default, and conditions. Don't touch the user's preference.
197
+ existingRule . default = underride . default ;
198
+ existingRule . conditions = underride . conditions ;
199
+ existingRule . actions = underride . actions ;
200
+ } else {
201
+ // Add the rule
202
+ const ruleId = underride . rule_id ;
203
+ logger . warn ( `Adding default global underride for ${ ruleId } ` ) ;
204
+ globalUnderrides . push ( underride ) ;
205
+ }
206
+ }
207
+
186
208
return newRules ;
187
209
}
188
210
0 commit comments