mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
UnifiedPush: correctly unregister the provider.
This commit is contained in:
committed by
Benoit Marty
parent
d2fbff09b8
commit
ad63f2b0c5
+1
-1
@@ -71,7 +71,7 @@ class UnifiedPushProvider @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun unregister(matrixClient: MatrixClient) {
|
override suspend fun unregister(matrixClient: MatrixClient) {
|
||||||
val clientSecret = pushClientSecret.getSecretForUser(matrixClient.sessionId)
|
val clientSecret = pushClientSecret.getSecretForUser(matrixClient.sessionId)
|
||||||
unRegisterUnifiedPushUseCase.execute(clientSecret)
|
unRegisterUnifiedPushUseCase.execute(matrixClient, clientSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getCurrentUserPushConfig(): CurrentUserPushConfig? {
|
override suspend fun getCurrentUserPushConfig(): CurrentUserPushConfig? {
|
||||||
|
|||||||
+11
-11
@@ -18,26 +18,26 @@ package io.element.android.libraries.pushproviders.unifiedpush
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
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 org.unifiedpush.android.connector.UnifiedPush
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class UnregisterUnifiedPushUseCase @Inject constructor(
|
class UnregisterUnifiedPushUseCase @Inject constructor(
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
// private val pushDataStore: PushDataStore,
|
|
||||||
private val unifiedPushStore: UnifiedPushStore,
|
private val unifiedPushStore: UnifiedPushStore,
|
||||||
// private val unifiedPushGatewayResolver: UnifiedPushGatewayResolver,
|
private val pusherSubscriber: PusherSubscriber,
|
||||||
) {
|
) {
|
||||||
suspend fun execute(clientSecret: String) {
|
suspend fun execute(matrixClient: MatrixClient, clientSecret: String) {
|
||||||
// val mode = BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_REALTIME
|
val endpoint = unifiedPushStore.getEndpoint(clientSecret)
|
||||||
// pushDataStore.setFdroidSyncBackgroundMode(mode)
|
val gateway = unifiedPushStore.getPushGateway(clientSecret)
|
||||||
try {
|
if (endpoint != null && gateway != null) {
|
||||||
unifiedPushStore.getEndpoint(clientSecret)?.let {
|
try {
|
||||||
Timber.d("Removing $it")
|
pusherSubscriber.unregisterPusher(matrixClient, endpoint, gateway)
|
||||||
// TODO pushersManager?.unregisterPusher(it)
|
} 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.storeUpEndpoint(null, clientSecret)
|
||||||
unifiedPushStore.storePushGateway(null, clientSecret)
|
unifiedPushStore.storePushGateway(null, clientSecret)
|
||||||
|
|||||||
Reference in New Issue
Block a user