From 5c9ce84807128fd7d3c39922e0542aecfc5911b3 Mon Sep 17 00:00:00 2001 From: Flavio Alescio Date: Wed, 8 Feb 2023 14:31:11 +0100 Subject: [PATCH 1/5] managing dont notify push rule --- RiotNSE/NotificationService.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index 6560290ab1..312ecbcf2e 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -382,7 +382,14 @@ class NotificationService: UNNotificationServiceExtension { let currentUserId = account.mxCredentials.userId let roomDisplayName = roomSummary?.displayname let pushRule = NotificationService.backgroundSyncService.pushRule(matching: event, roomState: roomState) - + + // if the actions contains the dont_notify one, we complete with nil and return + if let actions = pushRule?.actions as? [MXPushRuleAction], + actions.contains(where: { $0.actionType == MXPushRuleActionTypeDontNotify }) { + onComplete(nil, false) + return + } + switch event.eventType { case .callInvite: let offer = event.content["offer"] as? [AnyHashable: Any] From 2c89e9d7ac9f4f4754c075bb10f1a9216a2d3bca Mon Sep 17 00:00:00 2001 From: Flavio Alescio Date: Thu, 9 Feb 2023 12:01:05 +0100 Subject: [PATCH 2/5] add changelog --- changelog.d/pr-7356.change | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-7356.change diff --git a/changelog.d/pr-7356.change b/changelog.d/pr-7356.change new file mode 100644 index 0000000000..9755eb38c9 --- /dev/null +++ b/changelog.d/pr-7356.change @@ -0,0 +1 @@ +Polls: Apply push rules client side for encrypted rooms \ No newline at end of file From 66374e4ce94f15daef32fc37f177c826039e43f7 Mon Sep 17 00:00:00 2001 From: Flavio Alescio Date: Fri, 10 Feb 2023 17:13:05 +0100 Subject: [PATCH 3/5] private extension for push rule --- RiotNSE/NotificationService.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index 312ecbcf2e..f0c0b1fab6 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -383,9 +383,8 @@ class NotificationService: UNNotificationServiceExtension { let roomDisplayName = roomSummary?.displayname let pushRule = NotificationService.backgroundSyncService.pushRule(matching: event, roomState: roomState) - // if the actions contains the dont_notify one, we complete with nil and return - if let actions = pushRule?.actions as? [MXPushRuleAction], - actions.contains(where: { $0.actionType == MXPushRuleActionTypeDontNotify }) { + // if the push rule must not be notified we complete and return + if pushRule?.dontNotify == true { onComplete(nil, false) return } @@ -894,3 +893,10 @@ class NotificationService: UNNotificationServiceExtension { return String(format: format, locale: locale, arguments: args) } } + +private extension MXPushRule { + var dontNotify: Bool { + let actions = (actions as? [MXPushRuleAction]) ?? [] + return actions.contains { $0.actionType == MXPushRuleActionTypeDontNotify } + } +} From d4b555dff16617885a5d49932bf39069c0293351 Mon Sep 17 00:00:00 2001 From: Flavio Alescio Date: Fri, 10 Feb 2023 17:13:59 +0100 Subject: [PATCH 4/5] remove mentions and keyword notice footer --- .../View/MentionsAndKeywordNotificationSettings.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift b/RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift index ac1316bfd4..6139eb72b9 100644 --- a/RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift +++ b/RiotSwiftUI/Modules/Settings/Notifications/View/MentionsAndKeywordNotificationSettings.swift @@ -21,8 +21,7 @@ struct MentionsAndKeywordNotificationSettings: View { var keywordSection: some View { SwiftUI.Section( - header: FormSectionHeader(text: VectorL10n.settingsYourKeywords), - footer: FormSectionFooter(text: VectorL10n.settingsMentionsAndKeywordsEncryptionNotice) + header: FormSectionHeader(text: VectorL10n.settingsYourKeywords) ) { NotificationSettingsKeywords(viewModel: viewModel) } From ad716eb5c8d4f68c58791e4e592ced85013c1542 Mon Sep 17 00:00:00 2001 From: Flavio Alescio Date: Fri, 10 Feb 2023 17:40:36 +0100 Subject: [PATCH 5/5] better changelog --- changelog.d/pr-7356.change | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/pr-7356.change b/changelog.d/pr-7356.change index 9755eb38c9..d0f12bb922 100644 --- a/changelog.d/pr-7356.change +++ b/changelog.d/pr-7356.change @@ -1 +1 @@ -Polls: Apply push rules client side for encrypted rooms \ No newline at end of file +Push Rules: Apply push rules client side for encrypted rooms, hiding in case of dont_notify action \ No newline at end of file