From 6b3eeaab7e23ab6b020258e9aab25fe54beeca52 Mon Sep 17 00:00:00 2001 From: yostyle Date: Wed, 4 Jan 2023 15:13:31 +0100 Subject: [PATCH 1/3] Remove voice broadcast chunk notifications --- RiotNSE/NotificationService.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index 1d7f5cf074..39927d4d3d 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -774,6 +774,11 @@ class NotificationService: UNNotificationServiceExtension { return Constants.callInviteNotificationCategoryIdentifier } + // Ignore voice broadcast chunk event + if event.eventType == .roomMessage && event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] != nil { + return Constants.toBeRemovedNotificationCategoryIdentifier + } + guard event.eventType == .roomMessage || event.eventType == .roomEncrypted else { return Constants.toBeRemovedNotificationCategoryIdentifier } From 16c03c9c698277ba4a10f882aee566c3be28fb12 Mon Sep 17 00:00:00 2001 From: yostyle Date: Wed, 4 Jan 2023 15:19:25 +0100 Subject: [PATCH 2/3] Add changelog --- RiotNSE/NotificationService.swift | 10 ++++------ changelog.d/pr-7230.change | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 changelog.d/pr-7230.change diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index 39927d4d3d..da0acb1551 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -471,7 +471,10 @@ class NotificationService: UNNotificationServiceExtension { notificationBody = NotificationService.localizedString(forKey: "VIDEO_FROM_USER", eventSenderName) case kMXMessageTypeAudio: if event.isVoiceMessage() { - notificationBody = NotificationService.localizedString(forKey: "VOICE_MESSAGE_FROM_USER", eventSenderName) + // Ignore voice broadcast chunk event + if event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] == nil { + notificationBody = NotificationService.localizedString(forKey: "VOICE_MESSAGE_FROM_USER", eventSenderName) + } } else { notificationBody = NotificationService.localizedString(forKey: "AUDIO_FROM_USER", eventSenderName, messageContent) } @@ -774,11 +777,6 @@ class NotificationService: UNNotificationServiceExtension { return Constants.callInviteNotificationCategoryIdentifier } - // Ignore voice broadcast chunk event - if event.eventType == .roomMessage && event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] != nil { - return Constants.toBeRemovedNotificationCategoryIdentifier - } - guard event.eventType == .roomMessage || event.eventType == .roomEncrypted else { return Constants.toBeRemovedNotificationCategoryIdentifier } diff --git a/changelog.d/pr-7230.change b/changelog.d/pr-7230.change new file mode 100644 index 0000000000..d5b48aadce --- /dev/null +++ b/changelog.d/pr-7230.change @@ -0,0 +1 @@ +Ignore the voice broadcast chunks at the notifications level \ No newline at end of file From 0ff9c9405216aa65ab4ecef80d3de9ba290e9a7e Mon Sep 17 00:00:00 2001 From: yostyle Date: Tue, 10 Jan 2023 01:12:54 +0100 Subject: [PATCH 3/3] Send a notification on first chunk. --- Riot/Assets/en.lproj/Localizable.strings | 3 +++ RiotNSE/NotificationService.swift | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Riot/Assets/en.lproj/Localizable.strings b/Riot/Assets/en.lproj/Localizable.strings index f35b9b8a92..965fcfd4a4 100644 --- a/Riot/Assets/en.lproj/Localizable.strings +++ b/Riot/Assets/en.lproj/Localizable.strings @@ -83,6 +83,9 @@ /* Sticker from a specific person, not referencing a room. */ "STICKER_FROM_USER" = "%@ sent a sticker"; +/* New voice broadcast from a specific person, not referencing a room. */ +"VOICE_BROADCAST_FROM_USER" = "%@ started a voice broadcast"; + /** Notification messages **/ /* New message indicator on unknown room */ diff --git a/RiotNSE/NotificationService.swift b/RiotNSE/NotificationService.swift index da0acb1551..977a71e824 100644 --- a/RiotNSE/NotificationService.swift +++ b/RiotNSE/NotificationService.swift @@ -471,8 +471,12 @@ class NotificationService: UNNotificationServiceExtension { notificationBody = NotificationService.localizedString(forKey: "VIDEO_FROM_USER", eventSenderName) case kMXMessageTypeAudio: if event.isVoiceMessage() { - // Ignore voice broadcast chunk event - if event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] == nil { + // Ignore voice broadcast chunk event except the first one. + if let chunkInfo = event.content[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkType] as? [String: UInt] { + if chunkInfo[VoiceBroadcastSettings.voiceBroadcastContentKeyChunkSequence] == 1 { + notificationBody = NotificationService.localizedString(forKey: "VOICE_BROADCAST_FROM_USER", eventSenderName) + } + } else { notificationBody = NotificationService.localizedString(forKey: "VOICE_MESSAGE_FROM_USER", eventSenderName) } } else {