Refactor Rageshake URL and Target configuration. (#4337)

* Move the rageshakeURL configuration from the BugReportService to AppSettings.

* Refactor Target to return a handle when configuring.

This helps with reconfiguration and removes the @MainActor constraint.
This commit is contained in:
Doug
2025-07-22 10:19:26 +01:00
committed by GitHub
parent 97f517129f
commit 82c659f3da
17 changed files with 241 additions and 179 deletions
+16 -11
View File
@@ -28,12 +28,13 @@ import UserNotifications
// notification.
class NotificationServiceExtension: UNNotificationServiceExtension {
private static var targetConfiguration: Target.Configuration?
private var notificationHandler: NotificationHandler?
private let appHooks = AppHooks()
private let settings: CommonSettingsProtocol = AppSettings()
private let keychainController = KeychainController(service: .sessions,
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
@@ -44,6 +45,14 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
MXLog.info("\(tag) deinit")
}
override init() {
if Self.targetConfiguration == nil {
Self.targetConfiguration = Target.nse.configure(logLevel: settings.logLevel,
traceLogPacks: settings.traceLogPacks,
sentryURL: nil)
}
}
override func didReceive(_ request: UNNotificationRequest,
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
guard !DataProtectionManager.isDeviceLockedAfterReboot(containerURL: URL.appGroupContainerDirectory),
@@ -63,17 +72,13 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
return contentHandler(request.content)
}
MXLog.info("\(tag) #########################################")
ExtensionLogger.logMemory(with: tag)
MXLog.info("\(tag) Received payload: \(request.content.userInfo)")
Task {
await Target.nse.configure(logLevel: settings.logLevel,
traceLogPacks: settings.traceLogPacks,
sentryURL: nil)
MXLog.info("\(tag) #########################################")
ExtensionLogger.logMemory(with: tag)
MXLog.info("\(tag) Received payload: \(request.content.userInfo)")
do {
let userSession = try await NSEUserSession(credentials: credentials,
roomID: roomID,