From 24f7bb2b45ff90add1ccb6697b73b1ff2e42e4a0 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 6 Aug 2023 22:39:49 +0930 Subject: [PATCH] Move files --- .../securesms/notifications/PushRegistry.kt | 10 +++++----- .../securesms/notifications/PushRegistryV2.kt | 11 ++++++++--- .../notifications/FirebaseTokenFetcher.kt | 16 +++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) rename app/src/main/{kotlin => java}/org/thoughtcrime/securesms/notifications/PushRegistry.kt (94%) rename app/src/main/{kotlin => java}/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt (90%) diff --git a/app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistry.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt similarity index 94% rename from app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistry.kt rename to app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt index 872b2956a3..9a625f133c 100644 --- a/app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistry.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistry.kt @@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.crypto.KeyPairUtilities import javax.inject.Inject import javax.inject.Singleton -private const val TAG = "GenericPushManager" +private val TAG = PushRegistry::class.java.name @Singleton class PushRegistry @Inject constructor( @@ -26,16 +26,16 @@ class PushRegistry @Inject constructor( private val pushRegistryV2: PushRegistryV2, ) { - private var firebaseInstanceIdJob: Job? = null + private var pushRegistrationJob: Job? = null fun refresh(force: Boolean) { Log.d(TAG, "refresh() called with: force = $force") - firebaseInstanceIdJob?.apply { + pushRegistrationJob?.apply { if (force) cancel() else if (isActive) return } - firebaseInstanceIdJob = tokenManager.fetchToken() + pushRegistrationJob = tokenManager.fetchToken() } fun refresh(token: String?, force: Boolean): Promise<*, Exception> { @@ -113,4 +113,4 @@ class PushRegistry @Inject constructor( } success { tokenManager.fcmToken = null } -} +} \ No newline at end of file diff --git a/app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt similarity index 90% rename from app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt rename to app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt index d03af92e6d..4bef45ff97 100644 --- a/app/src/main/kotlin/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/PushRegistryV2.kt @@ -12,7 +12,12 @@ import nl.komponents.kovenant.functional.map import okhttp3.MediaType import okhttp3.Request import okhttp3.RequestBody -import org.session.libsession.messaging.sending_receiving.notifications.* +import org.session.libsession.messaging.sending_receiving.notifications.Response +import org.session.libsession.messaging.sending_receiving.notifications.Server +import org.session.libsession.messaging.sending_receiving.notifications.SubscriptionRequest +import org.session.libsession.messaging.sending_receiving.notifications.SubscriptionResponse +import org.session.libsession.messaging.sending_receiving.notifications.UnsubscribeResponse +import org.session.libsession.messaging.sending_receiving.notifications.UnsubscriptionRequest import org.session.libsession.snode.OnionRequestAPI import org.session.libsession.snode.SnodeAPI import org.session.libsession.snode.Version @@ -24,7 +29,7 @@ import org.session.libsignal.utilities.retryIfNeeded import javax.inject.Inject import javax.inject.Singleton -private const val TAG = "PushManagerV2" +private val TAG = PushRegistryV2::class.java.name private const val maxRetryCount = 4 @Singleton @@ -108,4 +113,4 @@ class PushRegistryV2 @Inject constructor(private val pushReceiver: PushReceiver) .also { if (it.isFailure()) throw Exception("error: ${it.message}.") } } } -} +} \ No newline at end of file diff --git a/app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt b/app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt index e0aa14f6d2..70f3fb4522 100644 --- a/app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt +++ b/app/src/play/kotlin/org/thoughtcrime/securesms/notifications/FirebaseTokenFetcher.kt @@ -27,17 +27,15 @@ class FirebaseTokenFetcher @Inject constructor( .process() } - private fun Task.process() { - when { - isSuccessful -> try { - result?.token?.let { - pushRegistry.get().refresh(it, force = true).get() - } - } catch (e: Exception) { - onFail(e) + private fun Task.process() = when { + isSuccessful -> try { + result?.token?.let { + pushRegistry.get().refresh(it, force = true).get() } - else -> exception?.let(::onFail) + } catch (e: Exception) { + onFail(e) } + else -> exception?.let(::onFail) } private fun onFail(e: Exception) = Log.e(TAG, "fetch failed", e)