UnifiedPush: correctly unregister the provider.
This commit is contained in:
parent
3d5fdfc22e
commit
eb0dcd6b8c
2 changed files with 12 additions and 12 deletions
|
|
@ -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? {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue