mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-29 15:40:55 +08:00
Ensure Boolean io.element.disable_network_constraint
is explicitly set in the .well-known file.
This commit is contained in:
parent
7884b9dd5e
commit
64a7de5326
@ -94,7 +94,7 @@ data class HomeServerCapabilities(
|
|||||||
/**
|
/**
|
||||||
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager, provided in Wellknown.
|
* If set to true, the SDK will not use the network constraint when configuring Worker for the WorkManager, provided in Wellknown.
|
||||||
*/
|
*/
|
||||||
val disableNetworkConstraint: Boolean = false,
|
val disableNetworkConstraint: Boolean? = null,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
enum class RoomCapabilitySupport {
|
enum class RoomCapabilitySupport {
|
||||||
|
@ -25,6 +25,7 @@ internal class MigrateSessionTo054(realm: DynamicRealm) : RealmMigrator(realm, 5
|
|||||||
override fun doMigrate(realm: DynamicRealm) {
|
override fun doMigrate(realm: DynamicRealm) {
|
||||||
realm.schema.get("HomeServerCapabilitiesEntity")
|
realm.schema.get("HomeServerCapabilitiesEntity")
|
||||||
?.addField(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, Boolean::class.java)
|
?.addField(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, Boolean::class.java)
|
||||||
|
?.setNullable(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, true)
|
||||||
?.forceRefreshOfHomeServerCapabilities()
|
?.forceRefreshOfHomeServerCapabilities()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ internal open class HomeServerCapabilitiesEntity(
|
|||||||
var canRedactEventWithRelations: Boolean = false,
|
var canRedactEventWithRelations: Boolean = false,
|
||||||
var externalAccountManagementUrl: String? = null,
|
var externalAccountManagementUrl: String? = null,
|
||||||
var authenticationIssuer: String? = null,
|
var authenticationIssuer: String? = null,
|
||||||
var disableNetworkConstraint: Boolean = false,
|
var disableNetworkConstraint: Boolean? = null,
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
|
@ -17,19 +17,24 @@
|
|||||||
package org.matrix.android.sdk.internal.session.workmanager
|
package org.matrix.android.sdk.internal.session.workmanager
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
|
||||||
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
|
import org.matrix.android.sdk.internal.session.homeserver.HomeServerCapabilitiesDataSource
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Suppress("RedundantIf")
|
||||||
internal class DefaultWorkManagerConfig @Inject constructor(
|
internal class DefaultWorkManagerConfig @Inject constructor(
|
||||||
private val credentials: Credentials,
|
private val credentials: Credentials,
|
||||||
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource,
|
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource,
|
||||||
) : WorkManagerConfig {
|
) : WorkManagerConfig {
|
||||||
override fun withNetworkConstraint(): Boolean {
|
override fun withNetworkConstraint(): Boolean {
|
||||||
return if (credentials.discoveryInformation?.disableNetworkConstraint == true) {
|
return if (credentials.discoveryInformation?.disableNetworkConstraint == true) {
|
||||||
|
// Boolean `io.element.disable_network_constraint` explicitly set to `true` in the login response
|
||||||
|
false
|
||||||
|
} else if (homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint == true) {
|
||||||
|
// Boolean `io.element.disable_network_constraint` explicitly set to `true` in the .well-known file
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint.orFalse().not()
|
// Default, use the Network constraint
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user