mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
"Poll start" event push notification (#1819)
* Handle polls in NotificationContentBuilder * Cleanup
This commit is contained in:
parent
7bde419e85
commit
ee0539f260
@ -33,15 +33,21 @@ struct NotificationContentBuilder {
|
||||
case .invite:
|
||||
return try await processInvited(notificationItem: notificationItem, mediaProvider: mediaProvider)
|
||||
case .timeline(let event):
|
||||
switch try? event.eventType() {
|
||||
guard let eventType = try? event.eventType() else {
|
||||
return processEmpty(notificationItem: notificationItem)
|
||||
}
|
||||
|
||||
switch eventType {
|
||||
case let .messageLike(content):
|
||||
switch content {
|
||||
case .roomMessage(let messageType, _):
|
||||
return try await processRoomMessage(notificationItem: notificationItem, messageType: messageType, mediaProvider: mediaProvider)
|
||||
case .poll(let question):
|
||||
return try await processPollStartEvent(notificationItem: notificationItem, pollQuestion: question, mediaProvider: mediaProvider)
|
||||
default:
|
||||
return processEmpty(notificationItem: notificationItem)
|
||||
}
|
||||
default:
|
||||
case .state:
|
||||
return processEmpty(notificationItem: notificationItem)
|
||||
}
|
||||
}
|
||||
@ -116,6 +122,12 @@ struct NotificationContentBuilder {
|
||||
return notification
|
||||
}
|
||||
|
||||
private func processPollStartEvent(notificationItem: NotificationItemProxyProtocol, pollQuestion: String, mediaProvider: MediaProviderProtocol?) async throws -> UNMutableNotificationContent {
|
||||
let notification = try await processCommonRoomMessage(notificationItem: notificationItem, mediaProvider: mediaProvider)
|
||||
notification.body = L10n.commonPollSummary(pollQuestion)
|
||||
return notification
|
||||
}
|
||||
|
||||
private func processCommonRoomMessage(notificationItem: NotificationItemProxyProtocol, mediaProvider: MediaProviderProtocol?) async throws -> UNMutableNotificationContent {
|
||||
var notification = baseMutableContent(for: notificationItem)
|
||||
notification.title = notificationItem.senderDisplayName ?? notificationItem.roomDisplayName
|
||||
|
Loading…
x
Reference in New Issue
Block a user