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.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
private const val TAG = "GenericPushManager"
|
private val TAG = PushRegistry::class.java.name
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PushRegistry @Inject constructor(
|
class PushRegistry @Inject constructor(
|
||||||
@ -26,16 +26,16 @@ class PushRegistry @Inject constructor(
|
|||||||
private val pushRegistryV2: PushRegistryV2,
|
private val pushRegistryV2: PushRegistryV2,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var firebaseInstanceIdJob: Job? = null
|
private var pushRegistrationJob: Job? = null
|
||||||
|
|
||||||
fun refresh(force: Boolean) {
|
fun refresh(force: Boolean) {
|
||||||
Log.d(TAG, "refresh() called with: force = $force")
|
Log.d(TAG, "refresh() called with: force = $force")
|
||||||
|
|
||||||
firebaseInstanceIdJob?.apply {
|
pushRegistrationJob?.apply {
|
||||||
if (force) cancel() else if (isActive) return
|
if (force) cancel() else if (isActive) return
|
||||||
}
|
}
|
||||||
|
|
||||||
firebaseInstanceIdJob = tokenManager.fetchToken()
|
pushRegistrationJob = tokenManager.fetchToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refresh(token: String?, force: Boolean): Promise<*, Exception> {
|
fun refresh(token: String?, force: Boolean): Promise<*, Exception> {
|
||||||
@ -113,4 +113,4 @@ class PushRegistry @Inject constructor(
|
|||||||
} success {
|
} success {
|
||||||
tokenManager.fcmToken = null
|
tokenManager.fcmToken = null
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,12 @@ import nl.komponents.kovenant.functional.map
|
|||||||
import okhttp3.MediaType
|
import okhttp3.MediaType
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.RequestBody
|
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.OnionRequestAPI
|
||||||
import org.session.libsession.snode.SnodeAPI
|
import org.session.libsession.snode.SnodeAPI
|
||||||
import org.session.libsession.snode.Version
|
import org.session.libsession.snode.Version
|
||||||
@ -24,7 +29,7 @@ import org.session.libsignal.utilities.retryIfNeeded
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
private const val TAG = "PushManagerV2"
|
private val TAG = PushRegistryV2::class.java.name
|
||||||
private const val maxRetryCount = 4
|
private const val maxRetryCount = 4
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -108,4 +113,4 @@ class PushRegistryV2 @Inject constructor(private val pushReceiver: PushReceiver)
|
|||||||
.also { if (it.isFailure()) throw Exception("error: ${it.message}.") }
|
.also { if (it.isFailure()) throw Exception("error: ${it.message}.") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,17 +27,15 @@ class FirebaseTokenFetcher @Inject constructor(
|
|||||||
.process()
|
.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Task<InstanceIdResult>.process() {
|
private fun Task<InstanceIdResult>.process() = when {
|
||||||
when {
|
isSuccessful -> try {
|
||||||
isSuccessful -> try {
|
result?.token?.let {
|
||||||
result?.token?.let {
|
pushRegistry.get().refresh(it, force = true).get()
|
||||||
pushRegistry.get().refresh(it, force = true).get()
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
onFail(e)
|
|
||||||
}
|
}
|
||||||
else -> exception?.let(::onFail)
|
} catch (e: Exception) {
|
||||||
|
onFail(e)
|
||||||
}
|
}
|
||||||
|
else -> exception?.let(::onFail)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFail(e: Exception) = Log.e(TAG, "fetch failed", e)
|
private fun onFail(e: Exception) = Log.e(TAG, "fetch failed", e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user