From 12a995bc917c39fcc856e47cc1c2466b9677af86 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 3 Aug 2021 13:47:11 +1000 Subject: [PATCH] enable only notify mention for closed groups --- .../Settings/OWSConversationSettingsViewController.m | 2 +- .../Meta/SessionNotificationServiceExtension.entitlements | 2 ++ .../NotificationServiceExtension.swift | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Session/Conversations/Settings/OWSConversationSettingsViewController.m b/Session/Conversations/Settings/OWSConversationSettingsViewController.m index 3d303ca9d..33a3823fa 100644 --- a/Session/Conversations/Settings/OWSConversationSettingsViewController.m +++ b/Session/Conversations/Settings/OWSConversationSettingsViewController.m @@ -515,7 +515,7 @@ CGFloat kIconViewLength = 24; [weakSelf.navigationController pushViewController:vc animated:YES]; }]]; - if (self.isOpenGroup) { + if (self.isGroupThread) { // Notification Settings [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ UITableViewCell *cell = [OWSTableItem newCell]; diff --git a/SessionNotificationServiceExtension/Meta/SessionNotificationServiceExtension.entitlements b/SessionNotificationServiceExtension/Meta/SessionNotificationServiceExtension.entitlements index 758088249..71a223d61 100644 --- a/SessionNotificationServiceExtension/Meta/SessionNotificationServiceExtension.entitlements +++ b/SessionNotificationServiceExtension/Meta/SessionNotificationServiceExtension.entitlements @@ -2,6 +2,8 @@ + com.apple.developer.usernotifications.filtering + aps-environment development com.apple.security.application-groups diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 2cb60549b..fd51ffd0b 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -61,7 +61,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension if let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction), let group = thread as? TSGroupThread, group.groupModel.groupType == .closedGroup { // Should always be true because we don't get PNs for open groups senderDisplayName = String(format: NotificationStrings.incomingGroupMessageTitleFormat, senderDisplayName, group.groupModel.groupName ?? MessageStrings.newGroupDefaultTitle) - if let messageBody = tsIncomingMessage.previewText(with: transaction).filterForDisplay, !messageBody.contains("@\(userPublicKey)") && group.isOnlyNotifyingForMentions { + if group.isOnlyNotifyingForMentions && !tsIncomingMessage.isUserMentioned { // Ignore PNs if the group is set to only notify mentions return self.completeSilenty() }