mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-25 15:08:12 +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.
|
||||
*/
|
||||
val disableNetworkConstraint: Boolean = false,
|
||||
val disableNetworkConstraint: Boolean? = null,
|
||||
) {
|
||||
|
||||
enum class RoomCapabilitySupport {
|
||||
|
@ -25,6 +25,7 @@ internal class MigrateSessionTo054(realm: DynamicRealm) : RealmMigrator(realm, 5
|
||||
override fun doMigrate(realm: DynamicRealm) {
|
||||
realm.schema.get("HomeServerCapabilitiesEntity")
|
||||
?.addField(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, Boolean::class.java)
|
||||
?.setNullable(HomeServerCapabilitiesEntityFields.DISABLE_NETWORK_CONSTRAINT, true)
|
||||
?.forceRefreshOfHomeServerCapabilities()
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ internal open class HomeServerCapabilitiesEntity(
|
||||
var canRedactEventWithRelations: Boolean = false,
|
||||
var externalAccountManagementUrl: String? = null,
|
||||
var authenticationIssuer: String? = null,
|
||||
var disableNetworkConstraint: Boolean = false,
|
||||
var disableNetworkConstraint: Boolean? = null,
|
||||
) : RealmObject() {
|
||||
|
||||
companion object
|
||||
|
@ -17,19 +17,24 @@
|
||||
package org.matrix.android.sdk.internal.session.workmanager
|
||||
|
||||
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 javax.inject.Inject
|
||||
|
||||
@Suppress("RedundantIf")
|
||||
internal class DefaultWorkManagerConfig @Inject constructor(
|
||||
private val credentials: Credentials,
|
||||
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource,
|
||||
) : WorkManagerConfig {
|
||||
override fun withNetworkConstraint(): Boolean {
|
||||
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
|
||||
} else {
|
||||
homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint.orFalse().not()
|
||||
// Default, use the Network constraint
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user