UnifiedPushGatewayResolver.getGateway cannot return null.

This commit is contained in:
Benoit Marty 2024-05-22 09:25:57 +02:00
parent 39bb6d3ff3
commit 6dcc16fc6b
2 changed files with 13 additions and 23 deletions

View file

@ -26,7 +26,7 @@ class UnifiedPushGatewayResolver @Inject constructor(
private val unifiedPushApiFactory: UnifiedPushApiFactory, private val unifiedPushApiFactory: UnifiedPushApiFactory,
private val coroutineDispatchers: CoroutineDispatchers, private val coroutineDispatchers: CoroutineDispatchers,
) { ) {
suspend fun getGateway(endpoint: String): String? { suspend fun getGateway(endpoint: String): String {
val gateway = UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL val gateway = UnifiedPushConfig.DEFAULT_PUSH_GATEWAY_HTTP_URL
try { try {
val url = URL(endpoint) val url = URL(endpoint)

View file

@ -76,15 +76,6 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
coroutineScope.launch { coroutineScope.launch {
val gateway = unifiedPushGatewayResolver.getGateway(endpoint) val gateway = unifiedPushGatewayResolver.getGateway(endpoint)
unifiedPushStore.storePushGateway(gateway, instance) unifiedPushStore.storePushGateway(gateway, instance)
if (gateway == null) {
Timber.tag(loggerTag.value).w("No gateway found for endpoint $endpoint")
endpointRegistrationHandler.registrationDone(
RegistrationResult(
clientSecret = instance,
result = Result.failure(IllegalStateException("No gateway found for endpoint $endpoint")),
)
)
} else {
val result = newGatewayHandler.handle(endpoint, gateway, instance) val result = newGatewayHandler.handle(endpoint, gateway, instance)
.onFailure { .onFailure {
Timber.tag(loggerTag.value).e(it, "Failed to handle new gateway") Timber.tag(loggerTag.value).e(it, "Failed to handle new gateway")
@ -99,7 +90,6 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
) )
) )
} }
}
guardServiceStarter.stop() guardServiceStarter.stop()
} }