mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Parse markdown and html from push notifications (#1688)
* Extract notification content building outside of the NotificationItemProxy. First step in a bigger refactoring of the NSE * Import the attributed string buider into the NSE, sort `sources` imports * Extract message event string building into the RoomMessageEventStringBuilder and reuse it building content for push notifications * Cleanup * Add changelog
This commit is contained in:
@@ -20,6 +20,7 @@ import UserNotifications
|
||||
|
||||
class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
private let settings = NSESettings()
|
||||
private let notificationContentBuilder = NotificationContentBuilder(messageEventStringBuilder: RoomMessageEventStringBuilder(attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: .homeDirectory)))
|
||||
private lazy var keychainController = KeychainController(service: .sessions,
|
||||
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
|
||||
private var handler: ((UNNotificationContent) -> Void)?
|
||||
@@ -85,10 +86,10 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
MXLog.info("\(tag) no notification for the event, discard")
|
||||
return discard()
|
||||
}
|
||||
|
||||
|
||||
// After the first processing, update the modified content
|
||||
modifiedContent = try await itemProxy.process(mediaProvider: nil)
|
||||
|
||||
modifiedContent = try await notificationContentBuilder.content(for: itemProxy, mediaProvider: nil)
|
||||
|
||||
guard itemProxy.hasMedia else {
|
||||
MXLog.info("\(tag) no media needed")
|
||||
|
||||
@@ -99,7 +100,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
MXLog.info("\(tag) process with media")
|
||||
|
||||
// There is some media to load, process it again
|
||||
if let latestContent = try? await itemProxy.process(mediaProvider: userSession.mediaProvider) {
|
||||
if let latestContent = try? await notificationContentBuilder.content(for: itemProxy, mediaProvider: userSession.mediaProvider) {
|
||||
// Processing finished, hopefully with some media
|
||||
modifiedContent = latestContent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user