Custom copy for notifications that contain mentions (#2050)

This commit is contained in:
Mauro
2023-11-09 19:12:11 +01:00
committed by GitHub
parent 019ca625ab
commit a4bc7b8e36
21 changed files with 139 additions and 90 deletions
+13 -2
View File
@@ -99,8 +99,19 @@ struct NotificationContentBuilder {
private func processRoomMessage(notificationItem: NotificationItemProxyProtocol, messageType: MessageType, mediaProvider: MediaProviderProtocol?) async throws -> UNMutableNotificationContent {
var notification = try await processCommonRoomMessage(notificationItem: notificationItem, mediaProvider: mediaProvider)
let senderDisplayName = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
notification.body = String(messageEventStringBuilder.buildAttributedString(for: messageType, senderDisplayName: senderDisplayName, prefixWithSenderName: false).characters)
let displayName = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
let message = String(messageEventStringBuilder.buildAttributedString(for: messageType, senderDisplayName: displayName, prefixWithSenderName: false).characters)
let body: String
if notificationItem.hasMention {
if let senderDisplayName = notificationItem.senderDisplayName {
body = L10n.notificationMentionedYouBody(senderDisplayName, message)
} else {
body = L10n.notificationMentionedYouFallbackBody(message)
}
} else {
body = message
}
notification.body = body
switch messageType {
case .image(content: let content):