Give ability to configure the UnifiedPush default push gateway.
This commit is contained in:
parent
cf60f943a8
commit
5cab146eed
8 changed files with 59 additions and 3 deletions
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2025 New Vector 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.libraries.pushproviders.unifiedpush
|
||||
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.features.enterprise.api.EnterpriseService
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import javax.inject.Inject
|
||||
|
||||
interface DefaultPushGatewayHttpUrlProvider {
|
||||
fun provide(): String
|
||||
}
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultDefaultPushGatewayHttpUrlProvider @Inject constructor(
|
||||
private val enterpriseService: EnterpriseService,
|
||||
) : DefaultPushGatewayHttpUrlProvider {
|
||||
override fun provide(): String {
|
||||
return enterpriseService.unifiedPushDefaultPushGateway() ?: UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ interface UnifiedPushGatewayUrlResolver {
|
|||
@ContributesBinding(AppScope::class)
|
||||
class DefaultUnifiedPushGatewayUrlResolver @Inject constructor(
|
||||
private val unifiedPushStore: UnifiedPushStore,
|
||||
private val defaultPushGatewayHttpUrlProvider: DefaultPushGatewayHttpUrlProvider,
|
||||
) : UnifiedPushGatewayUrlResolver {
|
||||
override fun resolve(
|
||||
gatewayResult: UnifiedPushGatewayResolverResult,
|
||||
|
|
@ -33,7 +34,7 @@ class DefaultUnifiedPushGatewayUrlResolver @Inject constructor(
|
|||
}
|
||||
UnifiedPushGatewayResolverResult.ErrorInvalidUrl,
|
||||
UnifiedPushGatewayResolverResult.NoMatrixGateway -> {
|
||||
UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL
|
||||
defaultPushGatewayHttpUrlProvider.provide()
|
||||
}
|
||||
is UnifiedPushGatewayResolverResult.Success -> {
|
||||
gatewayResult.gateway
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue