From 8cd4969a1d8c5e59de6037841d4333744cc292c7 Mon Sep 17 00:00:00 2001 From: David Langley Date: Fri, 29 Oct 2021 11:07:22 +0100 Subject: [PATCH 1/3] Add clientPermalinkBaseUrl and set in matrix-sdk options. --- Config/BuildSettings.swift | 6 ++++++ Config/CommonConfiguration.swift | 1 + 2 files changed, 7 insertions(+) diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index bb1b25a0a..4daf809ad 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -133,8 +133,14 @@ final class BuildSettings: NSObject { // Official Matrix ones "matrix.to": ["/"], "www.matrix.to": ["/"], + // Client Permalinks (for use with `BuildSettings.clientPermalinkBaseUrl`) +// "clienturl.com": ["/"], +// "www.clienturl.com": ["/"], ] + // For use in clients that use a custom base url for permalinks rather than matrix.to. + // This baseURL is used to generate permalinks within the app (E.g. timeline message permalinks). + static let clientPermalinkBaseUrl: String? = nil // MARK: - VoIP static var allowVoIPUsage: Bool { diff --git a/Config/CommonConfiguration.swift b/Config/CommonConfiguration.swift index b6aa77dad..f2e4b68dc 100644 --- a/Config/CommonConfiguration.swift +++ b/Config/CommonConfiguration.swift @@ -75,6 +75,7 @@ class CommonConfiguration: NSObject, Configurable { // Disable key backup on common sdkOptions.enableKeyBackupWhenStartingMXCrypto = false + sdkOptions.clientPermalinkBaseUrl = BuildSettings.clientPermalinkBaseUrl // Configure key provider delegate MXKeyProvider.sharedInstance().delegate = EncryptionKeyManager.shared } From cac64ed0f40ae6f079f1157784c130e0764b70ef Mon Sep 17 00:00:00 2001 From: David Langley Date: Thu, 4 Nov 2021 12:29:49 +0000 Subject: [PATCH 2/3] Expand on BuildingSetting description and add changelog --- Config/BuildSettings.swift | 6 ++++-- changelog.d/4981.feature | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/4981.feature diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 4daf809ad..d740eb29a 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -134,12 +134,14 @@ final class BuildSettings: NSObject { "matrix.to": ["/"], "www.matrix.to": ["/"], // Client Permalinks (for use with `BuildSettings.clientPermalinkBaseUrl`) -// "clienturl.com": ["/"], -// "www.clienturl.com": ["/"], +// "example.com": ["/"], +// "www.example.com": ["/"], ] // For use in clients that use a custom base url for permalinks rather than matrix.to. // This baseURL is used to generate permalinks within the app (E.g. timeline message permalinks). + // Optional String that when set is used as permalink base, when nil matrix.to format is used. + // Example value would be "https://www.example.com", note there is no trailing '/'. static let clientPermalinkBaseUrl: String? = nil // MARK: - VoIP diff --git a/changelog.d/4981.feature b/changelog.d/4981.feature new file mode 100644 index 000000000..2d1a3e79f --- /dev/null +++ b/changelog.d/4981.feature @@ -0,0 +1 @@ +Adds clientPermalinkBaseUrl for a custom permalink base url. From 7ba7decab5b3e487510c438b544638ed5c4cac8a Mon Sep 17 00:00:00 2001 From: David Langley Date: Thu, 4 Nov 2021 16:22:58 +0000 Subject: [PATCH 3/3] Update matrixPermalinkPaths -> permalinkSupportedHosts for consistency with android naming --- Config/BuildSettings.swift | 8 ++++---- Riot/Utils/Tools.m | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index d740eb29a..bd6b63d83 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -118,9 +118,9 @@ final class BuildSettings: NSObject { "https://element.io/help" - // MARk: - Matrix permalinks - // Paths for URLs that will considered as Matrix permalinks. Those permalinks are opened within the app - static let matrixPermalinkPaths: [String: [String]] = [ + // MARK: - Permalinks + // Hosts/Paths for URLs that will considered as valid permalinks. Those permalinks are opened within the app. + static let permalinkSupportedHosts: [String: [String]] = [ "app.element.io": [], "staging.element.io": [], "develop.element.io": [], @@ -142,7 +142,7 @@ final class BuildSettings: NSObject { // This baseURL is used to generate permalinks within the app (E.g. timeline message permalinks). // Optional String that when set is used as permalink base, when nil matrix.to format is used. // Example value would be "https://www.example.com", note there is no trailing '/'. - static let clientPermalinkBaseUrl: String? = nil + static let clientPermalinkBaseUrl: String? = "https://app.element.io" // MARK: - VoIP static var allowVoIPUsage: Bool { diff --git a/Riot/Utils/Tools.m b/Riot/Utils/Tools.m index 66fe38d0c..c939b0fd4 100644 --- a/Riot/Utils/Tools.m +++ b/Riot/Utils/Tools.m @@ -66,11 +66,11 @@ { BOOL isUniversalLink = NO; - for (NSString *matrixPermalinkHost in BuildSettings.matrixPermalinkPaths) + for (NSString *matrixPermalinkHost in BuildSettings.permalinkSupportedHosts) { if ([url.host isEqualToString:matrixPermalinkHost]) { - NSArray *hostPaths = BuildSettings.matrixPermalinkPaths[matrixPermalinkHost]; + NSArray *hostPaths = BuildSettings.permalinkSupportedHosts[matrixPermalinkHost]; if (hostPaths.count) { // iOS Patch: fix urls before using it