From dce5bafbe1fb9212fdf6cba0a1714e95eb83dc38 Mon Sep 17 00:00:00 2001 From: Lumaa Date: Sun, 23 Jun 2024 19:24:09 +0200 Subject: [PATCH] more clients and fixes --- Threaded/Data/AltClients.swift | 52 ++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/Threaded/Data/AltClients.swift b/Threaded/Data/AltClients.swift index 2bb6843..be2b3b6 100644 --- a/Threaded/Data/AltClients.swift +++ b/Threaded/Data/AltClients.swift @@ -32,8 +32,14 @@ final class AltClients { } static func profile(account: Account) -> String { - let url = account.url?.absoluteString.replacingOccurrences(of: "https://", with: Self.default) - return url ?? Self.default + let username = account.username + let server = account.acct.split(separator: "@")[1] + + return Self.profile(server: String(server), username: username) + } + + static func status(_ statusUrl: String) -> String { + return Self.default + "\(statusUrl.replacingOccurrences(of: "https://", with: ""))" } static func status(_ status: Status) -> String { @@ -43,8 +49,48 @@ final class AltClients { // - Ivory by Tapbots struct IvoryApp { + // official URL Schemes: https://tapbots.com/support/ivory/tips/urlschemes + static let `default` = "ivory://" - // Others found don't work? Maybe because of demo + static func profile(account: Account) -> String { + return "\(Self.default)acct/user_profile/\(account.acct)" + } + + static func profile(acct: String) -> String { + return "\(Self.default)acct/user_profile/\(acct)" + } + + static func createPost(_ text: String) -> String { + let compose = text.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "" + return "\(Self.default)acct/post?text=\(compose)" + } + } + + /// Threads by Meta Platforms only allows connections from inside their personal protocol just yet + struct ThreadsApp { + static let `default` = "barcelona://" + + static func profile(_ username: String) -> String { + return "\(Self.default)user?username=\(username)" + } + + static let settings = "\(Self.default)settings" + static let search = "\(Self.default)search" + + static func createPost(_ text: String) -> String { + let compose = text.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "" + return "\(Self.default)create?text=\(compose)" + } + } + + /// X by X Corp. only allows connections from inside their personal protocol + struct XApp { + static let `default` = "twitter://" + + static func createPost(_ text: String) -> String { + let compose = text.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? "" + return "\(Self.default)post?message=\(compose)" + } } }