add NotificationContentBuilderTests and use the Dynamic swift package to test the communicationContext
This commit is contained in:
@@ -110,13 +110,13 @@ struct NotificationContentBuilder {
|
||||
notificationContent.body = body
|
||||
|
||||
let name = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
|
||||
await addSenderIcon(notificationContent: ¬ificationContent,
|
||||
senderID: notificationItem.senderID,
|
||||
senderAvatarDisplayName: name,
|
||||
senderDisplayName: name,
|
||||
icon: icon(for: notificationItem),
|
||||
forcePlaceholder: userSession.inviteAvatarsVisibility == .off,
|
||||
mediaProvider: mediaProvider)
|
||||
await addCommunicationContext(notificationContent: ¬ificationContent,
|
||||
senderID: notificationItem.senderID,
|
||||
senderAvatarDisplayName: name,
|
||||
senderDisplayName: name,
|
||||
icon: icon(for: notificationItem),
|
||||
forcePlaceholder: userSession.inviteAvatarsVisibility == .off,
|
||||
mediaProvider: mediaProvider)
|
||||
}
|
||||
|
||||
private func processMessageLike(notificationContent: inout UNMutableNotificationContent,
|
||||
@@ -136,12 +136,12 @@ struct NotificationContentBuilder {
|
||||
|
||||
let senderDisplayName = notificationItem.hasMention ? L10n.notificationSenderMentionReply(senderAvatarDisplayName) : senderAvatarDisplayName
|
||||
|
||||
await addSenderIcon(notificationContent: ¬ificationContent,
|
||||
senderID: notificationItem.senderID,
|
||||
senderAvatarDisplayName: senderAvatarDisplayName,
|
||||
senderDisplayName: senderDisplayName,
|
||||
icon: icon(for: notificationItem),
|
||||
mediaProvider: mediaProvider)
|
||||
await addCommunicationContext(notificationContent: ¬ificationContent,
|
||||
senderID: notificationItem.senderID,
|
||||
senderAvatarDisplayName: senderAvatarDisplayName,
|
||||
senderDisplayName: senderDisplayName,
|
||||
icon: icon(for: notificationItem),
|
||||
mediaProvider: mediaProvider)
|
||||
}
|
||||
|
||||
private func icon(for notificationItem: NotificationItemProxyProtocol) -> NotificationIcon {
|
||||
@@ -231,13 +231,13 @@ struct NotificationContentBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private func addSenderIcon(notificationContent: inout UNMutableNotificationContent,
|
||||
senderID: String,
|
||||
senderAvatarDisplayName: String,
|
||||
senderDisplayName: String,
|
||||
icon: NotificationIcon,
|
||||
forcePlaceholder: Bool = false,
|
||||
mediaProvider: MediaProviderProtocol) async {
|
||||
private func addCommunicationContext(notificationContent: inout UNMutableNotificationContent,
|
||||
senderID: String,
|
||||
senderAvatarDisplayName: String,
|
||||
senderDisplayName: String,
|
||||
icon: NotificationIcon,
|
||||
forcePlaceholder: Bool = false,
|
||||
mediaProvider: MediaProviderProtocol) async {
|
||||
var fetchedImage: INImage?
|
||||
let image: INImage
|
||||
if !forcePlaceholder,
|
||||
@@ -297,7 +297,9 @@ struct NotificationContentBuilder {
|
||||
interaction.direction = .incoming
|
||||
|
||||
// Donate the interaction before updating notification content.
|
||||
try? await interaction.donate()
|
||||
if !ProcessInfo.isRunningTests {
|
||||
try? await interaction.donate()
|
||||
}
|
||||
|
||||
// Update notification content before displaying the
|
||||
// communication notification.
|
||||
|
||||
Reference in New Issue
Block a user