From 36727f7ab783f8bfa1b28c29ae5064fe6d77bd82 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 16 Oct 2023 10:50:16 +0200 Subject: [PATCH] Always register the pusher when application starts --- changelog.d/1481.bugfix | 1 + .../libraries/push/impl/PushersManager.kt | 25 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 changelog.d/1481.bugfix diff --git a/changelog.d/1481.bugfix b/changelog.d/1481.bugfix new file mode 100644 index 0000000000..6cb5e63d50 --- /dev/null +++ b/changelog.d/1481.bugfix @@ -0,0 +1 @@ +Always register the pusher when application starts diff --git a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt index 39ff4323a5..7f4ee63004 100644 --- a/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt +++ b/libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/PushersManager.kt @@ -63,20 +63,19 @@ class PushersManager @Inject constructor( override suspend fun registerPusher(matrixClient: MatrixClient, pushKey: String, gateway: String) { val userDataStore = userPushStoreFactory.create(matrixClient.sessionId) if (userDataStore.getCurrentRegisteredPushKey() == pushKey) { - Timber.tag(loggerTag.value).d("Unnecessary to register again the same pusher") - } else { - // Register the pusher to the server - matrixClient.pushersService().setHttpPusher( - createHttpPusher(pushKey, gateway, matrixClient.sessionId) - ).fold( - { - userDataStore.setCurrentRegisteredPushKey(pushKey) - }, - { throwable -> - Timber.tag(loggerTag.value).e(throwable, "Unable to register the pusher") - } - ) + Timber.tag(loggerTag.value) + .d("Unnecessary to register again the same pusher, but do it in case the pusher has been removed from the server") } + matrixClient.pushersService().setHttpPusher( + createHttpPusher(pushKey, gateway, matrixClient.sessionId) + ).fold( + { + userDataStore.setCurrentRegisteredPushKey(pushKey) + }, + { throwable -> + Timber.tag(loggerTag.value).e(throwable, "Unable to register the pusher") + } + ) } private suspend fun createHttpPusher(