mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 15:44:54 +00:00
Initial content scanner integration (#7139)
* Create a `ContentScanner` component: - Add `:features:contentscanner:api` module with the interface. - Implement the concrete component using the Rust SDK in `:libraries:matrix:impl`. This can be used to both set up the content scanner media fetching in the SDK Client and manually scanning media sources from the Android side * Create `ContentScannerUrlProvider` in a new `:features:contentscaner:api` module as a noop implementation Use it as a placeholder for the code to instantiate a `RustContentScanner` with the fetched URL and set it as part of the SDK client. * Expose the optional `ContentScanner` in the `@SessionScope` * Split the storage part of the Element well-known retriever so it can be reused for the non-session bound retriever. Also add the new `content_scanner_url` field to it. This will be used by the enterprise code to fetch the actual content scanner url. * Bump enterprise commit to have access to the actual content scanner url provider implementation * Fix tests and lint issues * Use the right namespace for `:features:contentscanner:api`, also use the right namespace for `impl` --------- Co-authored-by: Benoit Marty <benoitm@element.io>
This commit is contained in:
committed by
GitHub
parent
7c3d1e2e80
commit
885e042c12
@@ -15,6 +15,9 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.serialization.json)
|
||||
implementation(projects.libraries.androidutils)
|
||||
implementation(projects.libraries.wellknown.api)
|
||||
implementation(projects.libraries.wellknown.impl)
|
||||
implementation(projects.tests.testutils)
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.wellknown.test
|
||||
|
||||
import io.element.android.libraries.androidutils.json.DefaultJsonProvider
|
||||
import io.element.android.libraries.androidutils.json.JsonProvider
|
||||
import io.element.android.libraries.wellknown.api.ElementWellKnown
|
||||
import io.element.android.libraries.wellknown.api.ElementWellknownStore
|
||||
import io.element.android.libraries.wellknown.api.WellknownRetrieverResult
|
||||
import io.element.android.libraries.wellknown.impl.InternalElementWellKnown
|
||||
import io.element.android.libraries.wellknown.impl.map
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.JsonDecodingException
|
||||
import java.net.URL
|
||||
|
||||
class FakeElementWellknownStore(
|
||||
initialData: Map<String, WellknownRetrieverResult<ElementWellKnown>> = emptyMap(),
|
||||
private val jsonProvider: JsonProvider = DefaultJsonProvider(),
|
||||
) : ElementWellknownStore {
|
||||
private val cachedData = mutableMapOf<String, WellknownRetrieverResult<ElementWellKnown>>()
|
||||
|
||||
init {
|
||||
initialData.forEach { (url, result) ->
|
||||
cachedData[URL(url).host] = result
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun get(domain: String): WellknownRetrieverResult<ElementWellKnown> {
|
||||
return cachedData[domain] ?: WellknownRetrieverResult.NotFound
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
override suspend fun update(domain: String, wellknown: String): Result<Unit> {
|
||||
val json = jsonProvider()
|
||||
val mapped = try {
|
||||
json.decodeFromString<InternalElementWellKnown>(wellknown).map()
|
||||
} catch (e: JsonDecodingException) {
|
||||
return Result.failure(e)
|
||||
}
|
||||
cachedData[domain] = WellknownRetrieverResult.Success(mapped)
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun delete(domain: String): Result<Unit> {
|
||||
cachedData.remove(domain)
|
||||
return Result.success(Unit)
|
||||
}
|
||||
}
|
||||
+2
@@ -19,6 +19,7 @@ fun anElementWellKnown(
|
||||
notificationSound: String? = null,
|
||||
identityProviderAppScheme: String? = null,
|
||||
customRecoveryPassphrase: CustomRecoveryPassphrase? = null,
|
||||
contentScannerUrl: String? = null,
|
||||
) = ElementWellKnown(
|
||||
registrationHelperUrl = registrationHelperUrl,
|
||||
enforceElementPro = enforceElementPro,
|
||||
@@ -27,6 +28,7 @@ fun anElementWellKnown(
|
||||
notificationSound = notificationSound,
|
||||
identityProviderAppScheme = identityProviderAppScheme,
|
||||
customRecoveryPassphrase = customRecoveryPassphrase,
|
||||
contentScannerUrl = contentScannerUrl,
|
||||
)
|
||||
|
||||
fun aCustomRecoveryPassphrase(
|
||||
|
||||
Reference in New Issue
Block a user