From 093994b4749036eecf734debb355f545cf82ded4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 27 May 2024 13:33:00 -0700 Subject: [PATCH] More push subscription logging --- .../Sources/PushNotifications/PushManagerImpl.swift | 1 + Tusker/AppDelegate.swift | 3 ++- .../Preferences/Notifications/PushInstanceSettingsView.swift | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift b/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift index 5db5ae7e..a3784692 100644 --- a/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift +++ b/Packages/PushNotifications/Sources/PushNotifications/PushManagerImpl.swift @@ -104,6 +104,7 @@ class PushManagerImpl: _PushManager { self.subscriptions = await AsyncSequenceAdaptor(wrapping: subscriptions).map { let newEndpoint = await self.endpointURL(deviceToken: token, accountID: $0.accountID) guard newEndpoint != $0.endpoint else { + PushManager.logger.debug("Skipping update of push subscription with endpoint \($0.endpoint, privacy: .public)") return $0 } var copy = $0 diff --git a/Tusker/AppDelegate.swift b/Tusker/AppDelegate.swift index 82400f80..c24d1d9d 100644 --- a/Tusker/AppDelegate.swift +++ b/Tusker/AppDelegate.swift @@ -185,7 +185,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let mastodonController = MastodonController.getForAccount(account) do { let result = try await mastodonController.updatePushSubscription(subscription: $0) - PushManager.logger.debug("Updated push subscription \(result.id) on \(mastodonController.instanceURL)") + PushManager.logger.info("Updated push subscription \(result.id, privacy: .public) on \(mastodonController.instanceURL) with endpoint \($0.endpoint, privacy: .public)") + PushManager.logger.debug("New push subscription: \(String(describing: result))") return true } catch { PushManager.logger.error("Error updating push subscription: \(String(describing: error))") diff --git a/Tusker/Screens/Preferences/Notifications/PushInstanceSettingsView.swift b/Tusker/Screens/Preferences/Notifications/PushInstanceSettingsView.swift index a50c008a..916b141f 100644 --- a/Tusker/Screens/Preferences/Notifications/PushInstanceSettingsView.swift +++ b/Tusker/Screens/Preferences/Notifications/PushInstanceSettingsView.swift @@ -90,7 +90,7 @@ struct PushInstanceSettingsView: View { let mastodonController = await MastodonController.getForAccount(account) do { let result = try await mastodonController.createPushSubscription(subscription: subscription) - PushManager.logger.debug("Push subscription \(result.id) created on \(account.instanceURL)") + PushManager.logger.debug("Push subscription \(result.id, privacy: .public) created on \(account.instanceURL) with endpoint \(result.endpoint, privacy: .public)") self.subscription = subscription return true } catch { @@ -112,7 +112,7 @@ struct PushInstanceSettingsView: View { let mastodonController = await MastodonController.getForAccount(account) do { let result = try await mastodonController.updatePushSubscription(alerts: alerts, policy: policy) - PushManager.logger.debug("Push subscription \(result.id) updated on \(account.instanceURL)") + PushManager.logger.debug("Push subscription \(result.id, privacy: .public) updated on \(account.instanceURL)") await PushManager.shared.updateSubscription(account: account, alerts: alerts, policy: policy) subscription?.alerts = alerts subscription?.policy = policy