File tree Expand file tree Collapse file tree 8 files changed +59
-3
lines changed
api/src/main/kotlin/io/element/android/features/enterprise/api
impl/src/main/kotlin/io/element/android/features/enterprise/impl
test/src/main/kotlin/io/element/android/features/enterprise/test
libraries/pushproviders/unifiedpush
main/kotlin/io/element/android/libraries/pushproviders/unifiedpush
test/kotlin/io/element/android/libraries/pushproviders/unifiedpush Expand file tree Collapse file tree 8 files changed +59
-3
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ interface EnterpriseService {
19
19
fun semanticColorsDark (): SemanticColors
20
20
21
21
fun firebasePushGateway (): String?
22
+ fun unifiedPushDefaultPushGateway (): String?
22
23
}
Original file line number Diff line number Diff line change @@ -29,4 +29,5 @@ class DefaultEnterpriseService @Inject constructor() : EnterpriseService {
29
29
override fun semanticColorsDark (): SemanticColors = compoundColorsDark
30
30
31
31
override fun firebasePushGateway (): String? = null
32
+ override fun unifiedPushDefaultPushGateway (): String? = null
32
33
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class FakeEnterpriseService(
20
20
private val semanticColorsLightResult : () -> SemanticColors = { lambdaError() },
21
21
private val semanticColorsDarkResult : () -> SemanticColors = { lambdaError() },
22
22
private val firebasePushGatewayResult : () -> String? = { lambdaError() },
23
+ private val unifiedPushDefaultPushGatewayResult : () -> String? = { lambdaError() },
23
24
) : EnterpriseService {
24
25
override suspend fun isEnterpriseUser (sessionId : SessionId ): Boolean = simulateLongTask {
25
26
isEnterpriseUserResult(sessionId)
@@ -41,6 +42,10 @@ class FakeEnterpriseService(
41
42
return firebasePushGatewayResult()
42
43
}
43
44
45
+ override fun unifiedPushDefaultPushGateway (): String? {
46
+ return unifiedPushDefaultPushGatewayResult()
47
+ }
48
+
44
49
companion object {
45
50
const val A_FAKE_HOMESERVER = " a_fake_homeserver"
46
51
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ setupAnvil()
19
19
20
20
dependencies {
21
21
implementation(libs.dagger)
22
+ implementation(projects.features.enterprise.api)
22
23
implementation(projects.libraries.androidutils)
23
24
implementation(projects.libraries.core)
24
25
implementation(projects.libraries.matrix.api)
@@ -48,6 +49,7 @@ dependencies {
48
49
testImplementation(libs.test.robolectric)
49
50
testImplementation(libs.test.truth)
50
51
testImplementation(libs.test.turbine)
52
+ testImplementation(projects.features.enterprise.test)
51
53
testImplementation(projects.libraries.matrix.test)
52
54
testImplementation(projects.libraries.push.test)
53
55
testImplementation(projects.libraries.pushproviders.test)
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 New Vector Ltd.
3
+ *
4
+ * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5
+ * Please see LICENSE files in the repository root for full details.
6
+ */
7
+
8
+ package io.element.android.libraries.pushproviders.unifiedpush
9
+
10
+ import com.squareup.anvil.annotations.ContributesBinding
11
+ import io.element.android.features.enterprise.api.EnterpriseService
12
+ import io.element.android.libraries.di.AppScope
13
+ import javax.inject.Inject
14
+
15
+ interface DefaultPushGatewayHttpUrlProvider {
16
+ fun provide (): String
17
+ }
18
+
19
+ @ContributesBinding(AppScope ::class )
20
+ class DefaultDefaultPushGatewayHttpUrlProvider @Inject constructor(
21
+ private val enterpriseService : EnterpriseService ,
22
+ ) : DefaultPushGatewayHttpUrlProvider {
23
+ override fun provide (): String {
24
+ return enterpriseService.unifiedPushDefaultPushGateway() ? : UnifiedPushConfig .DEFAULT_PUSH_GATEWAY_HTTP_URL
25
+ }
26
+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ interface UnifiedPushGatewayUrlResolver {
21
21
@ContributesBinding(AppScope ::class )
22
22
class DefaultUnifiedPushGatewayUrlResolver @Inject constructor(
23
23
private val unifiedPushStore : UnifiedPushStore ,
24
+ private val defaultPushGatewayHttpUrlProvider : DefaultPushGatewayHttpUrlProvider ,
24
25
) : UnifiedPushGatewayUrlResolver {
25
26
override fun resolve (
26
27
gatewayResult : UnifiedPushGatewayResolverResult ,
@@ -33,7 +34,7 @@ class DefaultUnifiedPushGatewayUrlResolver @Inject constructor(
33
34
}
34
35
UnifiedPushGatewayResolverResult .ErrorInvalidUrl ,
35
36
UnifiedPushGatewayResolverResult .NoMatrixGateway -> {
36
- UnifiedPushConfig . DEFAULT_PUSH_GATEWAY_HTTP_URL
37
+ defaultPushGatewayHttpUrlProvider.provide()
37
38
}
38
39
is UnifiedPushGatewayResolverResult .Success -> {
39
40
gatewayResult.gateway
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class DefaultUnifiedPushGatewayUrlResolverTest {
18
18
gatewayResult = UnifiedPushGatewayResolverResult .ErrorInvalidUrl ,
19
19
instance = " " ,
20
20
)
21
- assertThat(result).isEqualTo(UnifiedPushConfig . DEFAULT_PUSH_GATEWAY_HTTP_URL )
21
+ assertThat(result).isEqualTo(A_UNIFIED_PUSH_GATEWAY )
22
22
}
23
23
24
24
@Test
@@ -28,7 +28,7 @@ class DefaultUnifiedPushGatewayUrlResolverTest {
28
28
gatewayResult = UnifiedPushGatewayResolverResult .NoMatrixGateway ,
29
29
instance = " " ,
30
30
)
31
- assertThat(result).isEqualTo(UnifiedPushConfig . DEFAULT_PUSH_GATEWAY_HTTP_URL )
31
+ assertThat(result).isEqualTo(A_UNIFIED_PUSH_GATEWAY )
32
32
}
33
33
34
34
@Test
@@ -77,7 +77,9 @@ class DefaultUnifiedPushGatewayUrlResolverTest {
77
77
78
78
private fun createDefaultUnifiedPushGatewayUrlResolver (
79
79
unifiedPushStore : UnifiedPushStore = FakeUnifiedPushStore (),
80
+ defaultPushGatewayHttpUrlProvider : DefaultPushGatewayHttpUrlProvider = FakeDefaultPushGatewayHttpUrlProvider (),
80
81
) = DefaultUnifiedPushGatewayUrlResolver (
81
82
unifiedPushStore = unifiedPushStore,
83
+ defaultPushGatewayHttpUrlProvider = defaultPushGatewayHttpUrlProvider,
82
84
)
83
85
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 New Vector Ltd.
3
+ *
4
+ * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5
+ * Please see LICENSE files in the repository root for full details.
6
+ */
7
+
8
+ package io.element.android.libraries.pushproviders.unifiedpush
9
+
10
+ const val A_UNIFIED_PUSH_GATEWAY = " aGateway"
11
+
12
+ class FakeDefaultPushGatewayHttpUrlProvider (
13
+ private val provideResult : () -> String = { A_UNIFIED_PUSH_GATEWAY }
14
+ ) : DefaultPushGatewayHttpUrlProvider {
15
+ override fun provide (): String {
16
+ return provideResult()
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments