mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Include room display name in fallback content
This commit is contained in:
parent
2dd4b7dcc2
commit
b6fded100d
1 changed files with 12 additions and 0 deletions
|
@ -69,6 +69,8 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
|
||||
// setup user account
|
||||
setup(withRoomId: roomId, eventId: eventId) {
|
||||
// preprocess the payload, will attempt to fetch room display name
|
||||
self.preprocessPayload(forEventId: eventId, roomId: roomId)
|
||||
// fetch the event first
|
||||
self.fetchEvent(withEventId: eventId, roomId: roomId)
|
||||
}
|
||||
|
@ -124,6 +126,16 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
}
|
||||
}
|
||||
|
||||
/// Attempts to preprocess payload and attach room display name to the best attempt content
|
||||
/// - Parameters:
|
||||
/// - eventId: Event identifier to mutate best attempt content
|
||||
/// - roomId: Room identifier to fetch display name
|
||||
func preprocessPayload(forEventId eventId: String, roomId: String) {
|
||||
guard let session = NotificationService.mxSession else { return }
|
||||
guard let roomDisplayName = session.store.summary?(ofRoom: roomId)?.displayname else { return }
|
||||
originalContents[eventId]?.title = roomDisplayName
|
||||
}
|
||||
|
||||
func fetchEvent(withEventId eventId: String, roomId: String) {
|
||||
guard let mxSession = NotificationService.mxSession else {
|
||||
// there is something wrong, do not change the content
|
||||
|
|
Loading…
Reference in a new issue