Swiftify extension methods

Signed-off-by: ismailgulek <gulekismail@gmail.com>
This commit is contained in:
ismailgulek 2020-05-25 21:24:08 +03:00
parent f25e3b6c6b
commit 7f39581ee2
No known key found for this signature in database
GPG key ID: D3669D6148549402

View file

@ -464,30 +464,34 @@ class NotificationService: UNNotificationServiceExtension {
extension MXRoom {
func getRoomPushRule() -> MXPushRule? {
if let rules = self.mxSession.notificationCenter.rules.global.room {
guard let rules = self.mxSession.notificationCenter.rules.global.room else {
return nil
}
for rule in rules {
guard let pushRule = rule as? MXPushRule else { continue }
// the rule id is the room Id
// it is the server trick to avoid duplicated rule on the same room.
if (pushRule.ruleId == self.roomId) {
if pushRule.ruleId == self.roomId {
return pushRule
}
}
}
return nil
}
var isMentionsOnly: Bool {
// Check push rules at room level
if let rule = self.getRoomPushRule() {
guard let rule = self.getRoomPushRule() else {
return false
}
for ruleAction in rule.actions {
guard let action = ruleAction as? MXPushRuleAction else { continue }
if action.actionType == MXPushRuleActionTypeDontNotify {
return rule.enabled
}
}
}
return false
}