2020from synapse .push .rulekinds import PRIORITY_CLASS_INVERSE_MAP , PRIORITY_CLASS_MAP
2121
2222
23- def list_with_base_rules (
24- rawrules : List [Dict [str , Any ]], use_new_defaults : bool = False
25- ) -> List [Dict [str , Any ]]:
23+ def list_with_base_rules (rawrules : List [Dict [str , Any ]]) -> List [Dict [str , Any ]]:
2624 """Combine the list of rules set by the user with the default push rules
2725
2826 Args:
2927 rawrules: The rules the user has modified or set.
30- use_new_defaults: Whether to use the new experimental default rules when
31- appending or prepending default rules.
3228
3329 Returns:
3430 A new list with the rules set by the user combined with the defaults.
@@ -48,9 +44,7 @@ def list_with_base_rules(
4844
4945 ruleslist .extend (
5046 make_base_prepend_rules (
51- PRIORITY_CLASS_INVERSE_MAP [current_prio_class ],
52- modified_base_rules ,
53- use_new_defaults ,
47+ PRIORITY_CLASS_INVERSE_MAP [current_prio_class ], modified_base_rules
5448 )
5549 )
5650
@@ -61,7 +55,6 @@ def list_with_base_rules(
6155 make_base_append_rules (
6256 PRIORITY_CLASS_INVERSE_MAP [current_prio_class ],
6357 modified_base_rules ,
64- use_new_defaults ,
6558 )
6659 )
6760 current_prio_class -= 1
@@ -70,7 +63,6 @@ def list_with_base_rules(
7063 make_base_prepend_rules (
7164 PRIORITY_CLASS_INVERSE_MAP [current_prio_class ],
7265 modified_base_rules ,
73- use_new_defaults ,
7466 )
7567 )
7668
@@ -79,43 +71,29 @@ def list_with_base_rules(
7971 while current_prio_class > 0 :
8072 ruleslist .extend (
8173 make_base_append_rules (
82- PRIORITY_CLASS_INVERSE_MAP [current_prio_class ],
83- modified_base_rules ,
84- use_new_defaults ,
74+ PRIORITY_CLASS_INVERSE_MAP [current_prio_class ], modified_base_rules
8575 )
8676 )
8777 current_prio_class -= 1
8878 if current_prio_class > 0 :
8979 ruleslist .extend (
9080 make_base_prepend_rules (
91- PRIORITY_CLASS_INVERSE_MAP [current_prio_class ],
92- modified_base_rules ,
93- use_new_defaults ,
81+ PRIORITY_CLASS_INVERSE_MAP [current_prio_class ], modified_base_rules
9482 )
9583 )
9684
9785 return ruleslist
9886
9987
10088def make_base_append_rules (
101- kind : str ,
102- modified_base_rules : Dict [str , Dict [str , Any ]],
103- use_new_defaults : bool = False ,
89+ kind : str , modified_base_rules : Dict [str , Dict [str , Any ]]
10490) -> List [Dict [str , Any ]]:
10591 rules = []
10692
10793 if kind == "override" :
108- rules = (
109- NEW_APPEND_OVERRIDE_RULES
110- if use_new_defaults
111- else BASE_APPEND_OVERRIDE_RULES
112- )
94+ rules = BASE_APPEND_OVERRIDE_RULES
11395 elif kind == "underride" :
114- rules = (
115- NEW_APPEND_UNDERRIDE_RULES
116- if use_new_defaults
117- else BASE_APPEND_UNDERRIDE_RULES
118- )
96+ rules = BASE_APPEND_UNDERRIDE_RULES
11997 elif kind == "content" :
12098 rules = BASE_APPEND_CONTENT_RULES
12199
@@ -134,7 +112,6 @@ def make_base_append_rules(
134112def make_base_prepend_rules (
135113 kind : str ,
136114 modified_base_rules : Dict [str , Dict [str , Any ]],
137- use_new_defaults : bool = False ,
138115) -> List [Dict [str , Any ]]:
139116 rules = []
140117
@@ -301,135 +278,6 @@ def make_base_prepend_rules(
301278]
302279
303280
304- NEW_APPEND_OVERRIDE_RULES = [
305- {
306- "rule_id" : "global/override/.m.rule.encrypted" ,
307- "conditions" : [
308- {
309- "kind" : "event_match" ,
310- "key" : "type" ,
311- "pattern" : "m.room.encrypted" ,
312- "_id" : "_encrypted" ,
313- }
314- ],
315- "actions" : ["notify" ],
316- },
317- {
318- "rule_id" : "global/override/.m.rule.suppress_notices" ,
319- "conditions" : [
320- {
321- "kind" : "event_match" ,
322- "key" : "type" ,
323- "pattern" : "m.room.message" ,
324- "_id" : "_suppress_notices_type" ,
325- },
326- {
327- "kind" : "event_match" ,
328- "key" : "content.msgtype" ,
329- "pattern" : "m.notice" ,
330- "_id" : "_suppress_notices" ,
331- },
332- ],
333- "actions" : [],
334- },
335- {
336- "rule_id" : "global/underride/.m.rule.suppress_edits" ,
337- "conditions" : [
338- {
339- "kind" : "event_match" ,
340- "key" : "m.relates_to.m.rel_type" ,
341- "pattern" : "m.replace" ,
342- "_id" : "_suppress_edits" ,
343- }
344- ],
345- "actions" : [],
346- },
347- {
348- "rule_id" : "global/override/.m.rule.invite_for_me" ,
349- "conditions" : [
350- {
351- "kind" : "event_match" ,
352- "key" : "type" ,
353- "pattern" : "m.room.member" ,
354- "_id" : "_member" ,
355- },
356- {
357- "kind" : "event_match" ,
358- "key" : "content.membership" ,
359- "pattern" : "invite" ,
360- "_id" : "_invite_member" ,
361- },
362- {"kind" : "event_match" , "key" : "state_key" , "pattern_type" : "user_id" },
363- ],
364- "actions" : ["notify" , {"set_tweak" : "sound" , "value" : "default" }],
365- },
366- {
367- "rule_id" : "global/override/.m.rule.contains_display_name" ,
368- "conditions" : [{"kind" : "contains_display_name" }],
369- "actions" : [
370- "notify" ,
371- {"set_tweak" : "sound" , "value" : "default" },
372- {"set_tweak" : "highlight" },
373- ],
374- },
375- {
376- "rule_id" : "global/override/.m.rule.tombstone" ,
377- "conditions" : [
378- {
379- "kind" : "event_match" ,
380- "key" : "type" ,
381- "pattern" : "m.room.tombstone" ,
382- "_id" : "_tombstone" ,
383- },
384- {
385- "kind" : "event_match" ,
386- "key" : "state_key" ,
387- "pattern" : "" ,
388- "_id" : "_tombstone_statekey" ,
389- },
390- ],
391- "actions" : [
392- "notify" ,
393- {"set_tweak" : "sound" , "value" : "default" },
394- {"set_tweak" : "highlight" },
395- ],
396- },
397- {
398- "rule_id" : "global/override/.m.rule.roomnotif" ,
399- "conditions" : [
400- {
401- "kind" : "event_match" ,
402- "key" : "content.body" ,
403- "pattern" : "@room" ,
404- "_id" : "_roomnotif_content" ,
405- },
406- {
407- "kind" : "sender_notification_permission" ,
408- "key" : "room" ,
409- "_id" : "_roomnotif_pl" ,
410- },
411- ],
412- "actions" : [
413- "notify" ,
414- {"set_tweak" : "highlight" },
415- {"set_tweak" : "sound" , "value" : "default" },
416- ],
417- },
418- {
419- "rule_id" : "global/override/.m.rule.call" ,
420- "conditions" : [
421- {
422- "kind" : "event_match" ,
423- "key" : "type" ,
424- "pattern" : "m.call.invite" ,
425- "_id" : "_call" ,
426- }
427- ],
428- "actions" : ["notify" , {"set_tweak" : "sound" , "value" : "ring" }],
429- },
430- ]
431-
432-
433281BASE_APPEND_UNDERRIDE_RULES = [
434282 {
435283 "rule_id" : "global/underride/.m.rule.call" ,
@@ -538,36 +386,6 @@ def make_base_prepend_rules(
538386]
539387
540388
541- NEW_APPEND_UNDERRIDE_RULES = [
542- {
543- "rule_id" : "global/underride/.m.rule.room_one_to_one" ,
544- "conditions" : [
545- {"kind" : "room_member_count" , "is" : "2" , "_id" : "member_count" },
546- {
547- "kind" : "event_match" ,
548- "key" : "content.body" ,
549- "pattern" : "*" ,
550- "_id" : "body" ,
551- },
552- ],
553- "actions" : ["notify" , {"set_tweak" : "sound" , "value" : "default" }],
554- },
555- {
556- "rule_id" : "global/underride/.m.rule.message" ,
557- "conditions" : [
558- {
559- "kind" : "event_match" ,
560- "key" : "content.body" ,
561- "pattern" : "*" ,
562- "_id" : "body" ,
563- },
564- ],
565- "actions" : ["notify" ],
566- "enabled" : False ,
567- },
568- ]
569-
570-
571389BASE_RULE_IDS = set ()
572390
573391for r in BASE_APPEND_CONTENT_RULES :
@@ -589,26 +407,3 @@ def make_base_prepend_rules(
589407 r ["priority_class" ] = PRIORITY_CLASS_MAP ["underride" ]
590408 r ["default" ] = True
591409 BASE_RULE_IDS .add (r ["rule_id" ])
592-
593-
594- NEW_RULE_IDS = set ()
595-
596- for r in BASE_APPEND_CONTENT_RULES :
597- r ["priority_class" ] = PRIORITY_CLASS_MAP ["content" ]
598- r ["default" ] = True
599- NEW_RULE_IDS .add (r ["rule_id" ])
600-
601- for r in BASE_PREPEND_OVERRIDE_RULES :
602- r ["priority_class" ] = PRIORITY_CLASS_MAP ["override" ]
603- r ["default" ] = True
604- NEW_RULE_IDS .add (r ["rule_id" ])
605-
606- for r in NEW_APPEND_OVERRIDE_RULES :
607- r ["priority_class" ] = PRIORITY_CLASS_MAP ["override" ]
608- r ["default" ] = True
609- NEW_RULE_IDS .add (r ["rule_id" ])
610-
611- for r in NEW_APPEND_UNDERRIDE_RULES :
612- r ["priority_class" ] = PRIORITY_CLASS_MAP ["underride" ]
613- r ["default" ] = True
614- NEW_RULE_IDS .add (r ["rule_id" ])
0 commit comments