diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index bb1b25a0a..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": [], @@ -133,8 +133,16 @@ final class BuildSettings: NSObject { // Official Matrix ones "matrix.to": ["/"], "www.matrix.to": ["/"], + // Client Permalinks (for use with `BuildSettings.clientPermalinkBaseUrl`) +// "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? = "https://app.element.io" // 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 } 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 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.