mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-03 13:47:45 +00:00
Move files
This commit is contained in:
parent
bcf925c132
commit
24f7bb2b45
@ -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> {
|
@ -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
|
@ -27,8 +27,7 @@ class FirebaseTokenFetcher @Inject constructor(
|
||||
.process()
|
||||
}
|
||||
|
||||
private fun Task<InstanceIdResult>.process() {
|
||||
when {
|
||||
private fun Task<InstanceIdResult>.process() = when {
|
||||
isSuccessful -> try {
|
||||
result?.token?.let {
|
||||
pushRegistry.get().refresh(it, force = true).get()
|
||||
@ -38,7 +37,6 @@ class FirebaseTokenFetcher @Inject constructor(
|
||||
}
|
||||
else -> exception?.let(::onFail)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onFail(e: Exception) = Log.e(TAG, "fetch failed", e)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user