Add reaction content to notifications when available.

This commit is contained in:
Doug
2021-08-17 15:51:18 +01:00
parent 6165a89f33
commit 168a91fa42
2 changed files with 12 additions and 3 deletions

View File

@@ -119,8 +119,11 @@
/** Reactions **/
/* A user has reacted to a message */
"REACTION_FROM_USER" = "%@ sent a reaction";
/* A user has reacted to a message, including the reaction e.g. "Alice reacted 👍". */
"REACTION_FROM_USER" = "%@ reacted %@";
/* A user has reacted to a message, but the reaction content is unknown */
"GENERIC_REACTION_FROM_USER" = "%@ sent a reaction";
/** Invites **/

View File

@@ -439,7 +439,13 @@ class NotificationService: UNNotificationServiceExtension {
notificationBody = NSString.localizedUserNotificationString(forKey: "STICKER_FROM_USER", arguments: [eventSenderName as Any])
case .reaction:
notificationTitle = self.messageTitle(for: eventSenderName, in: roomDisplayName)
notificationBody = NSString.localizedUserNotificationString(forKey: "REACTION_FROM_USER", arguments: [eventSenderName])
if let reactionKey = event.relatesTo?.key {
// Try to show the reaction key in the notification.
notificationBody = NSString.localizedUserNotificationString(forKey: "REACTION_FROM_USER", arguments: [eventSenderName, reactionKey])
} else {
// Otherwise show a generic reaction.
notificationBody = NSString.localizedUserNotificationString(forKey: "GENERIC_REACTION_FROM_USER", arguments: [eventSenderName])
}
case .custom:
if (event.type == kWidgetMatrixEventTypeString || event.type == kWidgetModularEventTypeString),
let type = event.content?["type"] as? String,