Make the remote settings hook usable within the app extensions. (#4342)

This commit is contained in:
Doug
2025-07-22 17:09:53 +01:00
committed by GitHub
parent 82c659f3da
commit 5e165be8c3
20 changed files with 245 additions and 139 deletions
@@ -29,12 +29,10 @@ import UserNotifications
class NotificationServiceExtension: UNNotificationServiceExtension {
private static var targetConfiguration: Target.Configuration?
private var notificationHandler: NotificationHandler?
private let appHooks = AppHooks()
private let settings: CommonSettingsProtocol = AppSettings()
private let appHooks: AppHooks
private var notificationHandler: NotificationHandler?
private let keychainController = KeychainController(service: .sessions,
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
@@ -46,6 +44,9 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
}
override init() {
appHooks = AppHooks()
appHooks.setUp()
if Self.targetConfiguration == nil {
Self.targetConfiguration = Target.nse.configure(logLevel: settings.logLevel,
traceLogPacks: settings.traceLogPacks,
@@ -68,6 +69,9 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
return contentHandler(request.content)
}
let homeserverURL = credentials.restorationToken.session.homeserverUrl
appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: settings)
guard let mutableContent = request.content.mutableCopy() as? UNMutableNotificationContent else {
return contentHandler(request.content)
}