Skip to content

Commit

Permalink
Update the NetworkConstraint handling in WorkManager config
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Oct 13, 2023
1 parent 64a7de5 commit 3aa5f34
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ internal class DefaultWorkManagerConfig @Inject constructor(
private val homeServerCapabilitiesDataSource: HomeServerCapabilitiesDataSource,
) : WorkManagerConfig {
override fun withNetworkConstraint(): Boolean {
return if (credentials.discoveryInformation?.disableNetworkConstraint == true) {
val disableNetworkConstraint = homeServerCapabilitiesDataSource.getHomeServerCapabilities()?.disableNetworkConstraint
return if (disableNetworkConstraint != null) {
// Boolean `io.element.disable_network_constraint` explicitly set in the .well-known file
disableNetworkConstraint.not()
}
else 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 {
}
else {
// Default, use the Network constraint
true
}
Expand Down

0 comments on commit 3aa5f34

Please sign in to comment.