File tree 5 files changed +23
-12
lines changed
5 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ import Foundation
82
82
return false
83
83
}
84
84
85
+ // Support for MSC3987: The dont_notify push rule action is deprecated.
86
+ if rule. actions. isEmpty {
87
+ return rule. enabled
88
+ }
89
+
90
+ // Compatibility support.
85
91
for ruleAction in rule. actions {
86
92
guard let action = ruleAction as? MXPushRuleAction else { continue }
87
93
if action. actionType == MXPushRuleActionTypeDontNotify {
Original file line number Diff line number Diff line change @@ -1816,43 +1816,43 @@ - (MXHTTPOperation *)addPushRule:(NSString*)ruleId
1816
1816
{
1817
1817
case MXPushRuleKindOverride:
1818
1818
kindString = @" override" ;
1819
- if (conditions.count && actions. count )
1819
+ if (conditions.count && actions)
1820
1820
{
1821
1821
content = @{@" conditions" : conditions, @" actions" : actions};
1822
1822
}
1823
- else if (actions. count )
1823
+ else if (actions)
1824
1824
{
1825
1825
content = @{@" actions" : actions};
1826
1826
}
1827
1827
break ;
1828
1828
case MXPushRuleKindContent:
1829
1829
kindString = @" content" ;
1830
- if (pattern.length && actions. count )
1830
+ if (pattern.length && actions)
1831
1831
{
1832
1832
content = @{@" pattern" : pattern, @" actions" : actions};
1833
1833
}
1834
1834
break ;
1835
1835
case MXPushRuleKindRoom:
1836
1836
kindString = @" room" ;
1837
- if (actions. count )
1837
+ if (actions)
1838
1838
{
1839
1839
content = @{@" actions" : actions};
1840
1840
}
1841
1841
break ;
1842
1842
case MXPushRuleKindSender:
1843
1843
kindString = @" sender" ;
1844
- if (actions. count )
1844
+ if (actions)
1845
1845
{
1846
1846
content = @{@" actions" : actions};
1847
1847
}
1848
1848
break ;
1849
1849
case MXPushRuleKindUnderride:
1850
1850
kindString = @" underride" ;
1851
- if (conditions.count && actions. count )
1851
+ if (conditions.count && actions)
1852
1852
{
1853
1853
content = @{@" conditions" : conditions, @" actions" : actions};
1854
1854
}
1855
- else if (actions. count )
1855
+ else if (actions)
1856
1856
{
1857
1857
content = @{@" actions" : actions};
1858
1858
}
Original file line number Diff line number Diff line change @@ -579,6 +579,7 @@ - (NSArray*)encodeActionsWithNotify:(BOOL)notify
579
579
highlight : (BOOL )highlight
580
580
{
581
581
NSMutableArray *actions = [NSMutableArray array ];
582
+ // Support for MSC3987: The dont_notify push rule action is deprecated and replaced by an empty actions list.
582
583
if (notify)
583
584
{
584
585
[actions addObject: @" notify" ];
@@ -597,10 +598,6 @@ - (NSArray*)encodeActionsWithNotify:(BOOL)notify
597
598
[actions addObject: @{@" set_tweak" : @" highlight" , @" value" : @NO }];
598
599
}
599
600
}
600
- else
601
- {
602
- [actions addObject: @" dont_notify" ];
603
- }
604
601
return actions;
605
602
}
606
603
@@ -615,7 +612,8 @@ - (void)shouldNotify:(MXEvent*)event roomState:(MXRoomState*)roomState
615
612
if (rule)
616
613
{
617
614
// Make sure this is not a rule to prevent from generating a notification
618
- BOOL actionNotify = YES ;
615
+ // Support for MSC3987: The dont_notify push rule action is deprecated and replaced by an empty actions list.
616
+ BOOL actionNotify = (rule.actions .count > 0 );
619
617
if (1 == rule.actions .count )
620
618
{
621
619
MXPushRuleAction *action = rule.actions [0 ];
Original file line number Diff line number Diff line change @@ -225,6 +225,12 @@ public class MXSpaceNotificationCounter: NSObject {
225
225
continue
226
226
}
227
227
228
+ // Support for MSC3987: The dont_notify push rule action is deprecated.
229
+ if rule. actions. isEmpty {
230
+ return rule. enabled
231
+ }
232
+
233
+ // Compatibility support.
228
234
for ruleAction in ruleActions where ruleAction. actionType == MXPushRuleActionTypeDontNotify {
229
235
return rule. enabled
230
236
}
Original file line number Diff line number Diff line change
1
+ MSC3987 implementation: the 'dont_notify' action for a push_rule is now deprecated and replaced by an empty action list.
You can’t perform that action at this time.
0 commit comments