From 093994b4749036eecf734debb355f545cf82ded4 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 27 May 2024 13:33:00 -0700 Subject: [PATCH 1/3] 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 From f2a9f890ffd042365c2cbece0e743a2023f8ba30 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 27 May 2024 22:14:28 -0700 Subject: [PATCH 2/3] Use development URLSession in more places --- Tusker/Caching/ImageCache.swift | 2 +- Tusker/Screens/Conversation/ConversationViewController.swift | 2 +- Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift | 2 +- Tusker/Views/Attachments/AttachmentView.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tusker/Caching/ImageCache.swift b/Tusker/Caching/ImageCache.swift index 9949f5de..555a18bc 100644 --- a/Tusker/Caching/ImageCache.swift +++ b/Tusker/Caching/ImageCache.swift @@ -96,7 +96,7 @@ final class ImageCache: @unchecked Sendable { } private func fetch(url: URL) async -> FetchResult { - guard let (data, _) = try? await URLSession.shared.data(from: url) else { + guard let (data, _) = try? await URLSession.appDefault.data(from: url) else { return .none } guard let image = UIImage(data: data) else { diff --git a/Tusker/Screens/Conversation/ConversationViewController.swift b/Tusker/Screens/Conversation/ConversationViewController.swift index 43ae6ef7..f6bddcee 100644 --- a/Tusker/Screens/Conversation/ConversationViewController.swift +++ b/Tusker/Screens/Conversation/ConversationViewController.swift @@ -222,7 +222,7 @@ class ConversationViewController: UIViewController { } } if isLikelyMastodonRemoteStatus(url: url), - let (_, response) = try? await URLSession.shared.data(from: url, delegate: RedirectBlocker()), + let (_, response) = try? await URLSession.appDefault.data(from: url, delegate: RedirectBlocker()), let location = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "location") { effectiveURL = location } else { diff --git a/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift b/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift index 1119b12a..1d423090 100644 --- a/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift +++ b/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift @@ -98,7 +98,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource { case .unknown: return LoadingGalleryContentViewController(caption: nil) { do { - let (data, _) = try await URLSession.shared.data(from: attachment.url) + let (data, _) = try await URLSession.appDefault.data(from: attachment.url) let url = FileManager.default.temporaryDirectory.appendingPathComponent(attachment.url.lastPathComponent) try data.write(to: url) return FallbackGalleryNavigationController(url: url) diff --git a/Tusker/Views/Attachments/AttachmentView.swift b/Tusker/Views/Attachments/AttachmentView.swift index 42edf2ad..5b4353ca 100644 --- a/Tusker/Views/Attachments/AttachmentView.swift +++ b/Tusker/Views/Attachments/AttachmentView.swift @@ -511,7 +511,7 @@ extension AttachmentView: UIContextMenuInteractionDelegate { } else if self.attachment.kind == .gifv || self.attachment.kind == .video { itemSource = VideoActivityItemSource(asset: AVAsset(url: self.attachment.url), url: self.attachment.url) itemData = Task { - try? await URLSession.shared.data(from: self.attachment.url).0 + try? await URLSession.appDefault.data(from: self.attachment.url).0 } } else { return nil From 09999175f7f16892a2cd2cb5145ddf35de7408cf Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 27 May 2024 22:29:11 -0700 Subject: [PATCH 3/3] Fix editing attachment descriptions not working on Pleroma --- .../Sources/InstanceFeatures/InstanceFeatures.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift index 5ba74c2e..4783fc9d 100644 --- a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift +++ b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift @@ -157,7 +157,7 @@ public final class InstanceFeatures: ObservableObject { } public var needsEditAttachmentsInSeparateRequest: Bool { - instanceType.isPleroma(.akkoma(nil)) + instanceType.isPleroma } public var composeDirectStatuses: Bool {