UnifiedPush: correctly unregister the provider.
This commit is contained in:
committed by
Benoit Marty
parent
3d5fdfc22e
commit
eb0dcd6b8c
@@ -71,7 +71,7 @@ class UnifiedPushProvider @Inject constructor(
|
||||
|
||||
override suspend fun unregister(matrixClient: MatrixClient) {
|
||||
val clientSecret = pushClientSecret.getSecretForUser(matrixClient.sessionId)
|
||||
unRegisterUnifiedPushUseCase.execute(clientSecret)
|
||||
unRegisterUnifiedPushUseCase.execute(matrixClient, clientSecret)
|
||||
}
|
||||
|
||||
override suspend fun getCurrentUserPushConfig(): CurrentUserPushConfig? {
|
||||
|
||||
@@ -18,26 +18,26 @@ package io.element.android.libraries.pushproviders.unifiedpush
|
||||
|
||||
import android.content.Context
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.pushproviders.api.PusherSubscriber
|
||||
import org.unifiedpush.android.connector.UnifiedPush
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class UnregisterUnifiedPushUseCase @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
// private val pushDataStore: PushDataStore,
|
||||
private val unifiedPushStore: UnifiedPushStore,
|
||||
// private val unifiedPushGatewayResolver: UnifiedPushGatewayResolver,
|
||||
private val pusherSubscriber: PusherSubscriber,
|
||||
) {
|
||||
suspend fun execute(clientSecret: String) {
|
||||
// val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_REALTIME
|
||||
// pushDataStore.setFdroidSyncBackgroundMode(mode)
|
||||
try {
|
||||
unifiedPushStore.getEndpoint(clientSecret)?.let {
|
||||
Timber.d("Removing $it")
|
||||
// TODO pushersManager?.unregisterPusher(it)
|
||||
suspend fun execute(matrixClient: MatrixClient, clientSecret: String) {
|
||||
val endpoint = unifiedPushStore.getEndpoint(clientSecret)
|
||||
val gateway = unifiedPushStore.getPushGateway(clientSecret)
|
||||
if (endpoint != null && gateway != null) {
|
||||
try {
|
||||
pusherSubscriber.unregisterPusher(matrixClient, endpoint, gateway)
|
||||
} catch (e: Exception) {
|
||||
Timber.d(e, "Probably unregistering a non existing pusher")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.d(e, "Probably unregistering a non existing pusher")
|
||||
}
|
||||
unifiedPushStore.storeUpEndpoint(null, clientSecret)
|
||||
unifiedPushStore.storePushGateway(null, clientSecret)
|
||||
|
||||
Reference in New Issue
Block a user