From 84e6cd329800683a32fb57293fd569cfb33a2955 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Wed, 8 May 2024 19:37:46 +0200 Subject: [PATCH] Open strike in browser (IOS-264) --- .../Protocol/Provider/DataSourceFacade+Profile.swift | 2 +- .../DataSourceProvider+UITableViewDelegate.swift | 8 +++++++- .../Sources/MastodonSDK/API/Mastodon+API+Disputes.swift | 9 +++++++++ MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift | 4 ++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Disputes.swift diff --git a/Mastodon/Protocol/Provider/DataSourceFacade+Profile.swift b/Mastodon/Protocol/Provider/DataSourceFacade+Profile.swift index 89fd2547a..12285d871 100644 --- a/Mastodon/Protocol/Provider/DataSourceFacade+Profile.swift +++ b/Mastodon/Protocol/Provider/DataSourceFacade+Profile.swift @@ -143,7 +143,7 @@ extension DataSourceFacade { else { return } - let mentions = status.entity.mentions ?? [] + let mentions = status.entity.mentions guard let mention = mentions.first(where: { $0.url == href }) else { _ = provider.coordinator.present( diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift index c99e6790a..d5e654dca 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+UITableViewDelegate.swift @@ -44,7 +44,13 @@ extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvid status: status ) } else if let accountWarning = notification.entity.accountWarning { - print("// show account warning \(accountWarning.id) in safari") + let url = Mastodon.API.disputesEndpoint(domain: authContext.mastodonAuthenticationBox.domain, strikeId: accountWarning.id) + _ = coordinator.present( + scene: .safari(url: url), + from: self, + transition: .safariPresent(animated: true, completion: nil) + ) + } else { await DataSourceFacade.coordinateToProfileScene( provider: self, diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Disputes.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Disputes.swift new file mode 100644 index 000000000..21e22dad8 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API+Disputes.swift @@ -0,0 +1,9 @@ +// Copyright © 2024 Mastodon gGmbH. All rights reserved. + +import Foundation + +extension Mastodon.API { + public static func disputesEndpoint(domain: String, strikeId: String) -> URL { + return Mastodon.API.webURL(domain: domain).appendingPathComponent("disputes/strikes/\(strikeId)") + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift index b163a364b..60123608f 100644 --- a/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift +++ b/MastodonSDK/Sources/MastodonSDK/API/Mastodon+API.swift @@ -99,6 +99,10 @@ extension Mastodon.API { public static func profileSettingsURL(domain: String) -> URL { return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/auth/edit")! } + + public static func webURL(domain: String) -> URL { + return URL(string: "\(URL.httpScheme(domain: domain))://" + domain + "/")! + } } extension Mastodon.API {