mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Move the custom tile server URL config to the Element wellknown content (#7416)
* Move the custom tile server URL config to the Element wellknown content * Iteration: use whole `MapTilerConfig` in the remote config
This commit is contained in:
committed by
GitHub
parent
ddbc6a2a33
commit
22195a47f2
-5
@@ -255,11 +255,6 @@ interface MatrixClient : UrlContentFetcher {
|
||||
*/
|
||||
suspend fun performDatabaseVacuum(): Result<Unit>
|
||||
|
||||
/**
|
||||
* Returns the URL of the map style configured on the server, if any.
|
||||
*/
|
||||
suspend fun getMapStyleUrl(): Result<String?>
|
||||
|
||||
/**
|
||||
* Resets the cached client `well-known` config by the SDK.
|
||||
*/
|
||||
|
||||
-6
@@ -886,12 +886,6 @@ class RustMatrixClient(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getMapStyleUrl(): Result<String?> = withContext(sessionDispatcher) {
|
||||
runCatchingExceptions {
|
||||
innerClient.tileServer()?.mapStyleUrl
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun resetWellKnownConfig(): Result<Unit> {
|
||||
return runCatchingExceptions {
|
||||
Timber.d("Resetting well-known config for session $sessionId")
|
||||
|
||||
-5
@@ -129,7 +129,6 @@ class FakeMatrixClient(
|
||||
private val markRoomAsFullyReadResult: (RoomId, EventId) -> Result<Unit> = { _, _ -> lambdaError() },
|
||||
private val markAllRoomsAsReadResult: () -> Result<Unit> = { Result.success(Unit) },
|
||||
private val performDatabaseVacuumLambda: () -> Result<Unit> = { lambdaError() },
|
||||
private val getMapStyleUrlResult: () -> Result<String?> = { lambdaError() },
|
||||
private val getDatabaseSizesLambda: () -> Result<SdkStoreSizes> = { lambdaError() },
|
||||
private val resetWellKnownConfigLambda: () -> Result<Unit> = { lambdaError() },
|
||||
private val enableAutomaticCallStatusLambda: (Boolean) -> Unit = { },
|
||||
@@ -435,10 +434,6 @@ class FakeMatrixClient(
|
||||
return performDatabaseVacuumLambda()
|
||||
}
|
||||
|
||||
override suspend fun getMapStyleUrl(): Result<String?> = simulateLongTask {
|
||||
getMapStyleUrlResult()
|
||||
}
|
||||
|
||||
override suspend fun canLinkNewDevice(): Result<Boolean> = simulateLongTask {
|
||||
return canLinkNewDeviceResult()
|
||||
}
|
||||
|
||||
+15
@@ -18,4 +18,19 @@ data class ElementWellKnown(
|
||||
val customRecoveryPassphrase: CustomRecoveryPassphrase?,
|
||||
val contentScannerUrl: String?,
|
||||
val forceDisableE2EE: Boolean?,
|
||||
val mapTilerConfig: MapTilerConfig?,
|
||||
)
|
||||
|
||||
/**
|
||||
* A `MapTiler` configuration received from the server. This configuration is used to display maps in the app.
|
||||
*/
|
||||
data class MapTilerConfig(
|
||||
/** The API key to use with MapTiler. This is always not null, but can be empty/blank. */
|
||||
val apiKey: String,
|
||||
/** The style ID to use for light mode. This is optional and can be null. */
|
||||
val lightStyleId: String?,
|
||||
/** The style ID to use for light mode. This is optional and can be null. */
|
||||
val darkStyleId: String?,
|
||||
/** The base URL to use for MapTiler. This is optional and can be null. */
|
||||
val baseUrl: String?,
|
||||
)
|
||||
|
||||
+14
@@ -48,6 +48,8 @@ data class InternalElementWellKnown(
|
||||
val contentScannerUrl: String? = null,
|
||||
@SerialName("force_disable_e2ee")
|
||||
val forceDisableE2EE: Boolean? = null,
|
||||
@SerialName("map_tiler")
|
||||
val mapTilerConfig: InternalMapTilerConfig? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -55,3 +57,15 @@ data class InternalCustomRecoveryPassphrase(
|
||||
@SerialName("min_character_count")
|
||||
val minCharacterCount: Int? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class InternalMapTilerConfig(
|
||||
@SerialName("api_key")
|
||||
val apiKey: String,
|
||||
@SerialName("light_style_id")
|
||||
val lightStyleId: String? = null,
|
||||
@SerialName("dark_style_id")
|
||||
val darkStyleId: String? = null,
|
||||
@SerialName("base_url")
|
||||
val baseUrl: String? = null,
|
||||
)
|
||||
|
||||
+9
@@ -11,6 +11,7 @@ package io.element.android.libraries.wellknown.impl
|
||||
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||
import io.element.android.libraries.wellknown.api.CustomRecoveryPassphrase
|
||||
import io.element.android.libraries.wellknown.api.ElementWellKnown
|
||||
import io.element.android.libraries.wellknown.api.MapTilerConfig
|
||||
import timber.log.Timber
|
||||
|
||||
private val loggerTag = LoggerTag("Wellknown")
|
||||
@@ -32,6 +33,14 @@ fun InternalElementWellKnown.map() = ElementWellKnown(
|
||||
customRecoveryPassphrase = customRecoveryPassphrase?.toPublic(),
|
||||
contentScannerUrl = contentScannerUrl,
|
||||
forceDisableE2EE = forceDisableE2EE,
|
||||
mapTilerConfig = mapTilerConfig?.let {
|
||||
MapTilerConfig(
|
||||
apiKey = it.apiKey,
|
||||
lightStyleId = it.lightStyleId,
|
||||
darkStyleId = it.darkStyleId,
|
||||
baseUrl = it.baseUrl,
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
private fun InternalCustomRecoveryPassphrase.toPublic(): CustomRecoveryPassphrase {
|
||||
|
||||
+10
-1
@@ -13,6 +13,7 @@ package io.element.android.libraries.wellknown.impl
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
||||
import io.element.android.features.wellknown.test.FakeElementWellknownStore
|
||||
import io.element.android.features.wellknown.test.aMapTilerConfig
|
||||
import io.element.android.features.wellknown.test.anElementWellKnown
|
||||
import io.element.android.libraries.core.uri.ensureProtocol
|
||||
import io.element.android.libraries.matrix.api.UrlContentFetcher
|
||||
@@ -204,7 +205,11 @@ class DefaultWellknownRetrieverTest {
|
||||
"notification_sound": "a_notification_sound.flac",
|
||||
"idp_app_scheme": "an_app_scheme",
|
||||
"content_scanner_url": "https://content-scanner.example.com",
|
||||
"force_disable_e2ee": false
|
||||
"force_disable_e2ee": false,
|
||||
"map_tiler": {
|
||||
"api_key": "test_api_key",
|
||||
"base_url": "https://tile-server.example.com"
|
||||
}
|
||||
}"""
|
||||
|
||||
private val expectedElementWellKnown = ElementWellKnown(
|
||||
@@ -217,6 +222,10 @@ class DefaultWellknownRetrieverTest {
|
||||
contentScannerUrl = "https://content-scanner.example.com",
|
||||
customRecoveryPassphrase = null,
|
||||
forceDisableE2EE = false,
|
||||
mapTilerConfig = aMapTilerConfig(
|
||||
apiKey = "test_api_key",
|
||||
baseUrl = "https://tile-server.example.com",
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -10,6 +10,7 @@ package io.element.android.features.wellknown.test
|
||||
|
||||
import io.element.android.libraries.wellknown.api.CustomRecoveryPassphrase
|
||||
import io.element.android.libraries.wellknown.api.ElementWellKnown
|
||||
import io.element.android.libraries.wellknown.api.MapTilerConfig
|
||||
|
||||
fun anElementWellKnown(
|
||||
registrationHelperUrl: String? = null,
|
||||
@@ -21,6 +22,7 @@ fun anElementWellKnown(
|
||||
customRecoveryPassphrase: CustomRecoveryPassphrase? = null,
|
||||
contentScannerUrl: String? = null,
|
||||
forceDisableE2EE: Boolean? = null,
|
||||
mapTilerConfig: MapTilerConfig? = null,
|
||||
) = ElementWellKnown(
|
||||
registrationHelperUrl = registrationHelperUrl,
|
||||
enforceElementPro = enforceElementPro,
|
||||
@@ -31,6 +33,7 @@ fun anElementWellKnown(
|
||||
customRecoveryPassphrase = customRecoveryPassphrase,
|
||||
contentScannerUrl = contentScannerUrl,
|
||||
forceDisableE2EE = forceDisableE2EE,
|
||||
mapTilerConfig = mapTilerConfig,
|
||||
)
|
||||
|
||||
fun aCustomRecoveryPassphrase(
|
||||
@@ -38,3 +41,15 @@ fun aCustomRecoveryPassphrase(
|
||||
) = CustomRecoveryPassphrase(
|
||||
minCharacterCount = minCharacterCount,
|
||||
)
|
||||
|
||||
fun aMapTilerConfig(
|
||||
apiKey: String = "test_api_key",
|
||||
baseUrl: String? = null,
|
||||
lightStyleId: String? = null,
|
||||
darkStyleId: String? = null,
|
||||
) = MapTilerConfig(
|
||||
apiKey = apiKey,
|
||||
baseUrl = baseUrl,
|
||||
lightStyleId = lightStyleId,
|
||||
darkStyleId = darkStyleId,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user