remove map tiler url from matrix wellknown

This commit is contained in:
Mauro Romito
2026-08-04 13:42:51 +02:00
committed by Mauro
parent 80530f0006
commit 748ec818ac
22 changed files with 120 additions and 280 deletions
@@ -25,6 +25,7 @@ nonisolated protocol CommonSettingsProtocol: AnyObject, Sendable {
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
var contentScannerURL: RemotePreference<URL?> { get }
var forceDisableE2EE: RemotePreference<Bool> { get }
var mapTilerConfiguration: RemotePreference<MapTilerConfiguration> { get }
var enableOnlySignedDeviceIsolationMode: Bool { get }
var threadsEnabled: Bool { get }
@@ -95,7 +96,7 @@ final nonisolated class AppSettings: @unchecked Sendable {
accountProvisioningHost: String,
bugReportApplicationID: String,
analyticsTermsURL: URL?,
mapTilerConfiguration: MapTilerSettings.Configuration) {
mapTilerConfiguration: MapTilerConfiguration) {
self.accountProviders = accountProviders
self.allowOtherAccountProviders = allowOtherAccountProviders
self.hideBrandChrome = hideBrandChrome
@@ -116,7 +117,7 @@ final nonisolated class AppSettings: @unchecked Sendable {
self.accountProvisioningHost = accountProvisioningHost
self.bugReportApplicationID = bugReportApplicationID
self.analyticsTermsURL = analyticsTermsURL
mapTilerSettings = RemotePreference(.configuration(mapTilerConfiguration))
self.mapTilerConfiguration = RemotePreference(mapTilerConfiguration)
}
// MARK: - Application
@@ -376,15 +377,13 @@ final nonisolated class AppSettings: @unchecked Sendable {
// MARK: - Maps
/// The locally-bundled MapTiler configuration.
static let bundledMapTilerConfiguration = MapTilerSettings.Configuration(baseURL: "https://api.maptiler.com/maps",
apiKey: Secrets.mapLibreAPIKey,
lightStyleID: "9bc819c8-e627-474a-a348-ec144fe3d810",
darkStyleID: "dea61faf-292b-4774-9660-58fcef89a7f3")
static let bundledMapTilerConfiguration = MapTilerConfiguration(baseURL: "https://api.maptiler.com/maps",
apiKey: Secrets.mapLibreAPIKey,
lightStyleID: "9bc819c8-e627-474a-a348-ec144fe3d810",
darkStyleID: "dea61faf-292b-4774-9660-58fcef89a7f3")
/// The resolved map tile settings. Defaults to ``MapTilerSettings.configuration(_:)`` with the
/// bundled configuration and is remotely overridden with ``MapTilerSettings.url(_:)`` when
/// the homeserver advertises a `style.json` URL via the matrix client well-known.
private(set) var mapTilerSettings = RemotePreference<MapTilerSettings>(.configuration(AppSettings.bundledMapTilerConfiguration))
/// The MapTiler configuration used to build map URLs, which defaults to the bundled one.
private(set) var mapTilerConfiguration = RemotePreference(AppSettings.bundledMapTilerConfiguration)
// MARK: - Presence
@@ -0,0 +1,38 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
/// All of the configuration necessary to use MapTiler maps.
///
/// The style IDs need to be generated with the account that the API key belongs to. For more information read
/// [FORKING.md](https://github.com/element-hq/element-x-ios/blob/develop/docs/FORKING.md#setup-the-location-sharing)
nonisolated struct MapTilerConfiguration: Equatable, Codable {
let baseURL: URL
/// The API key for fetching map tiles. When empty, the server at ``baseURL`` is expected to
/// provide the key itself, so none is sent with the requests.
///
/// When not set, location sharing will be disabled and any received locations will be shown
/// in the timeline with a generic blurred map image.
let apiKey: String?
/// A MapLibre style ID for a light-mode map.
let lightStyleID: String
/// A MapLibre style ID for a dark-mode map.
let darkStyleID: String
enum CodingKeys: String, CodingKey {
case baseURL = "base_url"
case apiKey = "api_key"
case lightStyleID = "light_style_id"
case darkStyleID = "dark_style_id"
}
var isEnabled: Bool {
apiKey != nil
}
}
@@ -1,40 +0,0 @@
//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Foundation
/// The map tile settings used to build interactive and static map URLs.
///
/// Either resolves to a locally-bundled MapTiler configuration, or to a remote
/// `style.json` URL
nonisolated enum MapTilerSettings: Equatable {
/// All of the configuration necessary to use MapTiler maps.
///
/// The style IDs need to be generated with the account that the API key belongs to. For more information read
/// [FORKING.md](https://github.com/element-hq/element-x-ios/blob/develop/docs/FORKING.md#setup-the-location-sharing)
struct Configuration: Equatable {
let baseURL: URL
/// The API key for fetching map tiles. When not set, location sharing will be disabled and
/// any received locations will be shown in the timeline with a generic blurred map image.
let apiKey: String?
/// A MapLibre style ID for a light-mode map.
let lightStyleID: String
/// A MapLibre style ID for a dark-mode map.
let darkStyleID: String
}
case configuration(Configuration)
case url(URL)
var isEnabled: Bool {
switch self {
case .configuration(let configuration): configuration.apiKey != nil
case .url: true
}
}
}