diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixConfiguration.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixConfiguration.kt index d7c62f8bef..76873e438e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixConfiguration.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/MatrixConfiguration.kt @@ -22,6 +22,8 @@ import java.net.Proxy data class MatrixConfiguration( val applicationFlavor: String = "Default-application-flavor", val cryptoConfig: MXCryptoConfig = MXCryptoConfig(), + val integrationUIUrl: String = "https://scalar.vector.im/", + val integrationRestUrl: String = "https://scalar.vector.im/api", /** * Optional proxy to connect to the matrix servers * You can create one using for instance Proxy(proxyType, InetSocketAddress(hostname, port) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/integrationmanager/IntegrationManagerConfig.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/integrationmanager/IntegrationManagerConfig.kt index 6bc3d9a853..44a39ae3ff 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/integrationmanager/IntegrationManagerConfig.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/integrationmanager/IntegrationManagerConfig.kt @@ -20,7 +20,7 @@ package im.vector.matrix.android.api.session.integrationmanager */ data class IntegrationManagerConfig( val uiUrl: String, - val apiUrl: String, + val restUrl: String, val kind: Kind ) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/integrationmanager/IntegrationManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/integrationmanager/IntegrationManager.kt index 0e866412d7..a8c6bd4f06 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/integrationmanager/IntegrationManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/integrationmanager/IntegrationManager.kt @@ -20,9 +20,8 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import com.zhuinden.monarchy.Monarchy -import im.vector.matrix.android.R import im.vector.matrix.android.api.MatrixCallback -import im.vector.matrix.android.api.auth.wellknown.WellknownResult +import im.vector.matrix.android.api.MatrixConfiguration import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.integrationmanager.IntegrationManagerConfig import im.vector.matrix.android.api.session.integrationmanager.IntegrationManagerService @@ -31,7 +30,6 @@ import im.vector.matrix.android.api.session.widgets.model.WidgetType import im.vector.matrix.android.api.util.Cancelable import im.vector.matrix.android.api.util.NoOpCancellable import im.vector.matrix.android.internal.database.model.WellknownIntegrationManagerConfigEntity -import im.vector.matrix.android.internal.di.UserId import im.vector.matrix.android.internal.extensions.observeNotNull import im.vector.matrix.android.internal.session.SessionScope import im.vector.matrix.android.internal.session.sync.model.accountdata.UserAccountData @@ -43,9 +41,6 @@ import im.vector.matrix.android.internal.session.widgets.helper.extractWidgetSeq import im.vector.matrix.android.internal.task.TaskExecutor import im.vector.matrix.android.internal.task.configureWith import im.vector.matrix.android.internal.util.StringProvider -import im.vector.matrix.android.internal.util.awaitTransaction -import im.vector.matrix.android.internal.wellknown.GetWellknownTask -import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject @@ -62,14 +57,11 @@ import javax.inject.Inject * */ @SessionScope -internal class IntegrationManager @Inject constructor(@UserId private val userId: String, +internal class IntegrationManager @Inject constructor(matrixConfiguration: MatrixConfiguration, private val taskExecutor: TaskExecutor, private val monarchy: Monarchy, - private val stringProvider: StringProvider, private val updateUserAccountDataTask: UpdateUserAccountDataTask, private val accountDataDataSource: AccountDataDataSource, - private val getWellknownTask: GetWellknownTask, - private val configExtractor: IntegrationManagerConfigExtractor, private val widgetFactory: WidgetFactory) { private val currentConfigs = ArrayList() @@ -82,8 +74,8 @@ internal class IntegrationManager @Inject constructor(@UserId private val userId init { val defaultConfig = IntegrationManagerConfig( - uiUrl = stringProvider.getString(R.string.integrations_ui_url), - apiUrl = stringProvider.getString(R.string.integrations_rest_url), + uiUrl = matrixConfiguration.integrationUIUrl, + restUrl = matrixConfiguration.integrationRestUrl, kind = IntegrationManagerConfig.Kind.DEFAULT ) currentConfigs.add(defaultConfig) @@ -259,7 +251,7 @@ internal class IntegrationManager @Inject constructor(@UserId private val userId val integrationManagerData = data.toModel() return IntegrationManagerConfig( uiUrl = url, - apiUrl = integrationManagerData?.apiUrl ?: url, + restUrl = integrationManagerData?.apiUrl ?: url, kind = IntegrationManagerConfig.Kind.ACCOUNT ) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/DefaultWidgetURLFormatter.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/DefaultWidgetURLFormatter.kt index 411f17ceb5..2aaf5bbac7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/DefaultWidgetURLFormatter.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/widgets/DefaultWidgetURLFormatter.kt @@ -56,8 +56,8 @@ internal class DefaultWidgetURLFormatter @Inject constructor(private val integra val defaultWhiteList = stringProvider.getStringArray(R.array.integrations_widgets_urls).asList() whiteListedUrls = when (preferredConfig.kind) { IntegrationManagerConfig.Kind.DEFAULT -> defaultWhiteList - IntegrationManagerConfig.Kind.ACCOUNT -> defaultWhiteList + preferredConfig.apiUrl - IntegrationManagerConfig.Kind.HOMESERVER -> listOf(preferredConfig.apiUrl) + IntegrationManagerConfig.Kind.ACCOUNT -> defaultWhiteList + preferredConfig.restUrl + IntegrationManagerConfig.Kind.HOMESERVER -> listOf(preferredConfig.restUrl) } } } @@ -67,7 +67,7 @@ internal class DefaultWidgetURLFormatter @Inject constructor(private val integra */ override suspend fun format(baseUrl: String, params: Map, forceFetchScalarToken: Boolean, bypassWhitelist: Boolean): String { return if (bypassWhitelist || isWhiteListed(baseUrl)) { - val taskParams = GetScalarTokenTask.Params(currentConfig.apiUrl, forceFetchScalarToken) + val taskParams = GetScalarTokenTask.Params(currentConfig.restUrl, forceFetchScalarToken) val scalarToken = getScalarTokenTask.execute(taskParams) buildString { append(baseUrl) diff --git a/matrix-sdk-android/src/main/res/values/integration_manager_config.xml b/matrix-sdk-android/src/main/res/values/integration_manager_config.xml index 0180706810..7fc5b9d2b1 100644 --- a/matrix-sdk-android/src/main/res/values/integration_manager_config.xml +++ b/matrix-sdk-android/src/main/res/values/integration_manager_config.xml @@ -1,11 +1,6 @@ - - "https://scalar.vector.im/" - "https://scalar.vector.im/api" - "https://scalar.vector.im/api/widgets/jitsi.html" - https://scalar.vector.im/_matrix/integrations/v1 https://scalar.vector.im/api