mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-06 16:43:43 +00:00
Ensure UnifiedPush endpoint is registered.
This commit is contained in:
committed by
Benoit Marty
parent
7f9a30a033
commit
68708837d8
+12
-18
@@ -69,25 +69,19 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
|||||||
* You should send the endpoint to your application server and sync for missing notifications.
|
* You should send the endpoint to your application server and sync for missing notifications.
|
||||||
*/
|
*/
|
||||||
override fun onNewEndpoint(context: Context, endpoint: String, instance: String) {
|
override fun onNewEndpoint(context: Context, endpoint: String, instance: String) {
|
||||||
Timber.tag(loggerTag.value).i("onNewEndpoint: adding $endpoint")
|
Timber.tag(loggerTag.value).i("onNewEndpoint: $endpoint")
|
||||||
// If the endpoint has changed
|
coroutineScope.launch {
|
||||||
// or the gateway has changed
|
val gateway = unifiedPushGatewayResolver.getGateway(endpoint)
|
||||||
if (unifiedPushStore.getEndpoint(instance) != endpoint) {
|
unifiedPushStore.storePushGateway(gateway, instance)
|
||||||
coroutineScope.launch {
|
gateway?.let { pushGateway ->
|
||||||
val gateway = unifiedPushGatewayResolver.getGateway(endpoint)
|
newGatewayHandler.handle(endpoint, pushGateway, instance)
|
||||||
unifiedPushStore.storePushGateway(gateway, instance)
|
.onFailure {
|
||||||
gateway?.let { pushGateway ->
|
Timber.tag(loggerTag.value).e(it, "Failed to handle new gateway")
|
||||||
newGatewayHandler.handle(endpoint, pushGateway, instance)
|
}
|
||||||
.onFailure {
|
.onSuccess {
|
||||||
Timber.tag(loggerTag.value).e("Failed to handle new gateway")
|
unifiedPushStore.storeUpEndpoint(endpoint, instance)
|
||||||
}
|
}
|
||||||
.onSuccess {
|
|
||||||
unifiedPushStore.storeUpEndpoint(endpoint, instance)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Timber.tag(loggerTag.value).i("onNewEndpoint: skipped")
|
|
||||||
}
|
}
|
||||||
guardServiceStarter.stop()
|
guardServiceStarter.stop()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user