mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-09-20 00:35:47 +01:00
Move services into SignalNetwork.
This commit is contained in:
committed by
Cody Henthorne
parent
766f4a4c64
commit
7a474d0227
@@ -190,7 +190,7 @@ object BackupRepository {
|
||||
private val MANUAL_BACKUP_NOTIFICATION_THRESHOLD = 30.days
|
||||
|
||||
private val archiveService: ArchiveService
|
||||
get() = AppDependencies.archiveService
|
||||
get() = SignalNetwork.archiveService
|
||||
|
||||
/**
|
||||
* Generates a new AEP that the user can choose to confirm.
|
||||
@@ -1607,7 +1607,7 @@ object BackupRepository {
|
||||
|
||||
Log.w(TAG, "Resetting backup id reservation due to zk verification failure")
|
||||
|
||||
return when (val triggerResult = runBlocking { SignalNetwork.archiveV2.triggerBackupIdReservation(aep.deriveMessageBackupKey(), null, aci) }) {
|
||||
return when (val triggerResult = runBlocking { SignalNetwork.archiveApiV2.triggerBackupIdReservation(aep.deriveMessageBackupKey(), null, aci) }) {
|
||||
is RequestResult.Success -> {
|
||||
Log.i(TAG, "Reset successful, retrying aep verification")
|
||||
SignalStore.backup.messageCredentials.clearAll()
|
||||
@@ -1666,7 +1666,7 @@ object BackupRepository {
|
||||
|
||||
@WorkerThread
|
||||
fun getBackupLevelConfiguration(): NetworkResult<SubscriptionsConfiguration.BackupLevelConfiguration> {
|
||||
return AppDependencies.donationsService
|
||||
return SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
.toNetworkResult()
|
||||
.then {
|
||||
@@ -1681,7 +1681,7 @@ object BackupRepository {
|
||||
|
||||
@WorkerThread
|
||||
fun getFreeType(): NetworkResult<MessageBackupsType.Free> {
|
||||
return AppDependencies.donationsService
|
||||
return SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
.toNetworkResult()
|
||||
.map {
|
||||
@@ -1808,7 +1808,7 @@ object BackupRepository {
|
||||
}
|
||||
}
|
||||
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrB.restore(svrBAuth, messageBackupKey, forwardSecrecyMetadata)) {
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrBApi.restore(svrBAuth, messageBackupKey, forwardSecrecyMetadata)) {
|
||||
is SvrBApi.RestoreResult.Success -> {
|
||||
SignalStore.backup.nextBackupSecretData = result.data.nextBackupSecretData
|
||||
result.data.forwardSecrecyToken
|
||||
|
||||
+3
-3
@@ -16,8 +16,8 @@ import org.signal.network.service.successOrThrow
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.attachments.InvalidAttachmentException
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId
|
||||
@@ -115,7 +115,7 @@ fun DatabaseAttachment.createArchiveAttachmentPointer(useArchiveCdn: Boolean, ar
|
||||
return try {
|
||||
val (remoteId, cdnNumber) = if (useArchiveCdn) {
|
||||
val mediaRootBackupKey = SignalStore.backup.mediaRootBackupKey
|
||||
val mediaCdnPath = runBlocking { AppDependencies.archiveService.getArchivedMediaCdnPath() }.successOrThrow()
|
||||
val mediaCdnPath = runBlocking { SignalNetwork.archiveService.getArchivedMediaCdnPath() }.successOrThrow()
|
||||
|
||||
val id = SignalServiceAttachmentRemoteId.Backup(
|
||||
mediaCdnPath = mediaCdnPath,
|
||||
@@ -171,7 +171,7 @@ fun DatabaseAttachment.createArchiveThumbnailPointer(): SignalServiceAttachmentP
|
||||
}
|
||||
|
||||
val mediaRootBackupKey = SignalStore.backup.mediaRootBackupKey
|
||||
val mediaCdnPath = runBlocking { AppDependencies.archiveService.getArchivedMediaCdnPath() }.successOrThrow()
|
||||
val mediaCdnPath = runBlocking { SignalNetwork.archiveService.getArchivedMediaCdnPath() }.successOrThrow()
|
||||
return try {
|
||||
val key = mediaRootBackupKey.deriveThumbnailTransitKey(requireThumbnailMediaName())
|
||||
val mediaId = mediaRootBackupKey.deriveMediaId(requireThumbnailMediaName()).encode()
|
||||
|
||||
+2
-1
@@ -44,6 +44,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.InAppPaymentPurchaseTokenJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.whispersystems.signalservice.api.storage.IAPSubscriptionId
|
||||
@@ -87,7 +88,7 @@ class MessageBackupsFlowViewModel(
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
AppDependencies.archiveService
|
||||
SignalNetwork.archiveService
|
||||
.triggerBackupIdReservation()
|
||||
.onRight {
|
||||
Log.d(TAG, "Successfully triggered backup id reservation.")
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.getGiftBa
|
||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.internal.push.SubscriptionsConfiguration
|
||||
import java.util.Currency
|
||||
import java.util.Locale
|
||||
@@ -44,7 +44,7 @@ class GiftFlowRepository {
|
||||
fun getGiftBadge(): Single<Pair<Int, Badge>> {
|
||||
return Single
|
||||
.fromCallable {
|
||||
AppDependencies.donationsService
|
||||
SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
}
|
||||
.flatMap { it.flattenResult() }
|
||||
@@ -55,7 +55,7 @@ class GiftFlowRepository {
|
||||
fun getGiftPricing(): Single<Map<Currency, FiatMoney>> {
|
||||
return Single
|
||||
.fromCallable {
|
||||
AppDependencies.donationsService
|
||||
SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.getBadge
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.glide.OkHttpStreamFetcher
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import java.io.InputStream
|
||||
import java.security.MessageDigest
|
||||
import java.util.Locale
|
||||
@@ -52,7 +53,7 @@ data class GiftBadgeModel(val giftBadge: GiftBadge) : Key {
|
||||
override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
|
||||
try {
|
||||
val receiptCredentialPresentation = ReceiptCredentialPresentation(giftBadge.giftBadge.redemptionToken.toByteArray())
|
||||
val giftBadgeResponse = AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
val giftBadgeResponse = SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
if (giftBadgeResponse.result.isPresent) {
|
||||
val badge = giftBadgeResponse.result.get().getBadge(receiptCredentialPresentation.receiptLevel.toInt())
|
||||
okHttpStreamFetcher = OkHttpStreamFetcher(client, GlideUrl(badge.imageUrl.toString()))
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import java.time.Instant
|
||||
* all this layer does is hand the master key over and map the results into what the screens show.
|
||||
*/
|
||||
class TotpRepository(
|
||||
private val api: AccountApiV2 = SignalNetwork.accountV2,
|
||||
private val api: AccountApiV2 = SignalNetwork.accountApiV2,
|
||||
private val masterKeyProvider: () -> MasterKey = { SignalStore.svr.masterKey },
|
||||
private val clock: () -> Long = System::currentTimeMillis
|
||||
) {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class ExportAccountDataRepository {
|
||||
|
||||
fun downloadAccountDataReport(exportAsJson: Boolean): Single<ExportedReport> {
|
||||
return Single.create {
|
||||
when (val result = SignalNetwork.account.accountDataReport()) {
|
||||
when (val result = SignalNetwork.accountApi.accountDataReport()) {
|
||||
is NetworkResult.Success -> {
|
||||
it.onSuccess(generateAccountDataReport(result.result, exportAsJson))
|
||||
}
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.backup.v2.StagedBackupKeyRotations
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.RestoreOptimizedMediaJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
|
||||
class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler {
|
||||
|
||||
@@ -73,7 +74,7 @@ class BackupKeyDisplayViewModel : ViewModel(), BackupKeyCredentialManagerHandler
|
||||
|
||||
fun getKeyRotationLimit() {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
AppDependencies.archiveService
|
||||
SignalNetwork.archiveService
|
||||
.getKeyRotationLimit()
|
||||
.onRight { limit ->
|
||||
internalUiState.update { it.copy(canRotateKey = limit.hasPermitsRemaining ?: true) }
|
||||
|
||||
+2
-1
@@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.BackupMessagesConstraint
|
||||
import org.thoughtcrime.securesms.jobs.BackupMessagesJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.keyvalue.protos.ArchiveUploadProgressState
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.util.Environment
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
@@ -276,7 +277,7 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
|
||||
fun getKeyRotationLimit() {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
val canRotateKey = AppDependencies.archiveService
|
||||
val canRotateKey = SignalNetwork.archiveService
|
||||
.getKeyRotationLimit()
|
||||
.fold(
|
||||
ifRight = { it.hasPermitsRemaining!! },
|
||||
|
||||
+4
-4
@@ -140,7 +140,7 @@ class ChangeNumberRepository(
|
||||
Log.i(TAG, "Submitting prekeys with PNI identity key: ${pniIdentityKeyPair.publicKey.fingerprint}")
|
||||
|
||||
retryChangeLocalNumberNetworkOperation {
|
||||
SignalNetwork.keys.setPreKeysSync(
|
||||
SignalNetwork.keysApi.setPreKeysSync(
|
||||
PreKeyUpload(
|
||||
serviceIdType = ServiceIdType.PNI,
|
||||
signedPreKey = signedPreKey,
|
||||
@@ -227,8 +227,8 @@ class ChangeNumberRepository(
|
||||
|
||||
for (certificateType in certificateTypes) {
|
||||
val certificate: ByteArray? = when (certificateType) {
|
||||
CertificateType.ACI_AND_E164 -> retryChangeLocalNumberNetworkOperation { SignalNetwork.certificate.getSenderCertificate() }.successOrThrow()
|
||||
CertificateType.ACI_ONLY -> retryChangeLocalNumberNetworkOperation { SignalNetwork.certificate.getSenderCertificateForPhoneNumberPrivacy() }.successOrThrow()
|
||||
CertificateType.ACI_AND_E164 -> retryChangeLocalNumberNetworkOperation { SignalNetwork.certificateApi.getSenderCertificate() }.successOrThrow()
|
||||
CertificateType.ACI_ONLY -> retryChangeLocalNumberNetworkOperation { SignalNetwork.certificateApi.getSenderCertificateForPhoneNumberPrivacy() }.successOrThrow()
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ class ChangeNumberRepository(
|
||||
SignalStore.misc.setPendingChangeNumberMetadata(metadata)
|
||||
SignalStore.misc.lockChangeNumber()
|
||||
withContext(Dispatchers.IO) {
|
||||
result = SignalNetwork.account.changeNumber(request)
|
||||
result = SignalNetwork.accountApi.changeNumber(request)
|
||||
}
|
||||
|
||||
if (result is NetworkResult.StatusCodeError && result.code == 409) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import org.signal.core.util.money.FiatMoney
|
||||
import org.thoughtcrime.securesms.badges.Badges
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.DonationSerializationHelper.toFiatValue
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.PendingOneTimeDonation
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import java.math.BigDecimal
|
||||
import java.util.Currency
|
||||
import java.util.Locale
|
||||
@@ -35,7 +35,7 @@ class InternalPendingOneTimeDonationConfigurationViewModel : ViewModel() {
|
||||
|
||||
val disposable: Disposable = Single
|
||||
.fromCallable {
|
||||
AppDependencies.donationsService
|
||||
SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
}
|
||||
.flatMap { it.flattenResult() }
|
||||
|
||||
+5
-5
@@ -223,12 +223,12 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
throw IOException("Failed to read forward secrecy metadata!")
|
||||
}
|
||||
|
||||
val svrBAuth = when (val result = runBlocking { AppDependencies.archiveService.getSvrBAuth() }) {
|
||||
val svrBAuth = when (val result = runBlocking { SignalNetwork.archiveService.getSvrBAuth() }) {
|
||||
is Either.Right -> result.value
|
||||
is Either.Left -> throw IOException("Failed to read forward secrecy metadata!")
|
||||
}
|
||||
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrB.restore(svrBAuth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrBApi.restore(svrBAuth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
is SvrBApi.RestoreResult.Success -> result.data.forwardSecrecyToken
|
||||
else -> throw IOException("Failed to read forward secrecy metadata! $result")
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
disposables += Single
|
||||
.fromCallable {
|
||||
BackupRepository.restoreBackupFileTimestamp()
|
||||
runBlocking { AppDependencies.archiveService.debugGetRemoteBackupState() }
|
||||
runBlocking { SignalNetwork.archiveService.debugGetRemoteBackupState() }
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe { result ->
|
||||
@@ -369,7 +369,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
launch {
|
||||
statsState.update { it.copy(loadingRemoteStats = true) }
|
||||
val (remoteState: DebugBackupMetadata?, errorMsg: String?) = when (val result = AppDependencies.archiveService.debugGetRemoteBackupState()) {
|
||||
val (remoteState: DebugBackupMetadata?, errorMsg: String?) = when (val result = SignalNetwork.archiveService.debugGetRemoteBackupState()) {
|
||||
is Either.Right -> result.value to null
|
||||
is Either.Left -> null to result.value.toString()
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class InternalBackupPlaygroundViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
when (val result = AppDependencies.archiveService.deleteMessageBackup()) {
|
||||
when (val result = SignalNetwork.archiveService.deleteMessageBackup()) {
|
||||
is Either.Right -> {
|
||||
SignalStore.backup.messageBackupInitialized = false
|
||||
SignalStore.backup.mediaBackupInitialized = false
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.getBoostB
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.getGiftBadges
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.getSubscriptionLevels
|
||||
import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription
|
||||
import java.util.Locale
|
||||
import kotlin.concurrent.withLock
|
||||
@@ -30,7 +30,7 @@ class InternalDonorErrorConfigurationViewModel : ViewModel() {
|
||||
|
||||
init {
|
||||
viewModelScope.launch(SignalDispatchers.IO) {
|
||||
val configuration = AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault()).toNetworkResult().successOrNull() ?: return@launch
|
||||
val configuration = SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault()).toNetworkResult().successOrNull() ?: return@launch
|
||||
val giftBadges = configuration.getGiftBadges()
|
||||
val boostBadges = configuration.getBoostBadges()
|
||||
val subscriptionBadges = configuration.getSubscriptionLevels().values.map { Badges.fromServiceBadge(it.badge) }
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ import org.signal.core.util.ByteSize
|
||||
import org.signal.core.util.bytes
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.network.service.StorageServiceService
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageManifest
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageRecord
|
||||
|
||||
@@ -47,7 +47,7 @@ class InternalStorageServicePlaygroundViewModel : ViewModel() {
|
||||
fun onViewTabSelected() {
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
val repository = StorageServiceService(AppDependencies.storageServiceApi)
|
||||
val repository = SignalNetwork.storageService
|
||||
val storageKey = SignalStore.storageService.storageKeyForInitialDataRestore ?: SignalStore.storageService.storageKey
|
||||
|
||||
val manifest = when (val result = repository.getStorageManifest(storageKey)) {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ private val TAG = Log.tag(AdvancedPrivacySettingsRepository::class.java)
|
||||
class AdvancedPrivacySettingsRepository(private val context: Context) {
|
||||
|
||||
suspend fun disablePushMessages(): DisablePushMessagesResult = withContext(Dispatchers.IO) {
|
||||
val clearTokenError: Throwable? = when (val result = SignalNetwork.account.clearFcmToken()) {
|
||||
val clearTokenError: Throwable? = when (val result = SignalNetwork.accountApi.clearFcmToken()) {
|
||||
is RequestResult.Success, is RequestResult.NonSuccess -> null
|
||||
is RequestResult.RetryableNetworkError -> result.networkError
|
||||
is RequestResult.ApplicationError -> result.cause
|
||||
|
||||
+2
-1
@@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.PendingOneTimeDo
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.whispersystems.signalservice.api.storage.IAPSubscriptionId
|
||||
@@ -531,7 +532,7 @@ object InAppPaymentsRepository {
|
||||
}
|
||||
|
||||
if (latestSubscriber != null) {
|
||||
val remoteState = AppDependencies.donationsService.getSubscription(latestSubscriber.subscriberId)
|
||||
val remoteState = SignalNetwork.donationsService.getSubscription(latestSubscriber.subscriberId)
|
||||
val result = remoteState.result.getOrNull() ?: return localState
|
||||
|
||||
return result.activeSubscription?.isCanceled ?: localState
|
||||
|
||||
+4
-4
@@ -14,8 +14,8 @@ import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.InAppPaymentOneTimeContextJob
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import java.util.Currency
|
||||
@@ -76,7 +76,7 @@ object OneTimeInAppPaymentRepository {
|
||||
* based on platform and payment method availability.
|
||||
*/
|
||||
fun getBoosts(): Single<Map<Currency, List<Boost>>> {
|
||||
return Single.fromCallable { AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault()) }
|
||||
return Single.fromCallable { SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault()) }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.timeout(InAppPaymentsRepository.DONATIONS_CONFIGURATION_TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||
.flatMap { it.flattenResult() }
|
||||
@@ -95,7 +95,7 @@ object OneTimeInAppPaymentRepository {
|
||||
fun getBoostBadge(): Single<Badge> {
|
||||
return Single
|
||||
.fromCallable {
|
||||
AppDependencies.donationsService
|
||||
SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -109,7 +109,7 @@ object OneTimeInAppPaymentRepository {
|
||||
* signal service. This is scheduled on the io thread-pool.
|
||||
*/
|
||||
fun getMinimumDonationAmounts(): Single<Map<Currency, FiatMoney>> {
|
||||
return Single.fromCallable { AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault()) }
|
||||
return Single.fromCallable { SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault()) }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.timeout(InAppPaymentsRepository.DONATIONS_CONFIGURATION_TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||
.flatMap { it.flattenResult() }
|
||||
|
||||
+3
-3
@@ -20,11 +20,11 @@ import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.InAppPaymentSubscriberRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobs.InAppPaymentKeepAliveJob
|
||||
import org.thoughtcrime.securesms.jobs.InAppPaymentRecurringContextJob
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceSubscriptionSyncRequestJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.subscription.LevelUpdate
|
||||
@@ -49,7 +49,7 @@ object RecurringInAppPaymentRepository {
|
||||
|
||||
private val TAG = Log.tag(RecurringInAppPaymentRepository::class.java)
|
||||
|
||||
private val donationsService = AppDependencies.donationsService
|
||||
private val donationsService = SignalNetwork.donationsService
|
||||
|
||||
/**
|
||||
* Passthrough Rx wrapper for [getActiveSubscriptionSync] dispatching on io thread-pool.
|
||||
@@ -289,7 +289,7 @@ object RecurringInAppPaymentRepository {
|
||||
|
||||
Log.d(TAG, "Attempting to set user subscription level to $subscriptionLevel", true)
|
||||
|
||||
val response = AppDependencies.donationsService.updateSubscriptionLevel(
|
||||
val response = SignalNetwork.donationsService.updateSubscriptionLevel(
|
||||
subscriber.subscriberId,
|
||||
subscriptionLevel,
|
||||
subscriber.currency!!.currencyCode,
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.thoughtcrime.securesms.badges.Badges
|
||||
import org.thoughtcrime.securesms.badges.models.Badge
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.TerminalDonationQueue
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.services.DonationsService
|
||||
import java.util.Locale
|
||||
|
||||
class TerminalDonationRepository(
|
||||
private val donationsService: DonationsService = AppDependencies.donationsService
|
||||
private val donationsService: DonationsService = SignalNetwork.donationsService
|
||||
) {
|
||||
fun getBadge(terminalDonation: TerminalDonationQueue.TerminalDonation): Single<Badge> {
|
||||
return Single
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.getAvaila
|
||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.InAppPaymentData
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.payments.currency.CurrencyUtil
|
||||
import org.whispersystems.signalservice.internal.push.SubscriptionsConfiguration
|
||||
import java.util.Locale
|
||||
@@ -16,7 +16,7 @@ import java.util.Locale
|
||||
object GatewaySelectorRepository {
|
||||
fun getAvailableGatewayConfiguration(currencyCode: String): Single<GatewayConfiguration> {
|
||||
return Single.fromCallable {
|
||||
AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
}.flatMap { it.flattenResult() }
|
||||
.map { configuration ->
|
||||
val available = configuration.getAvailablePaymentMethods(currencyCode).map {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ package org.thoughtcrime.securesms.components.settings.app.subscription.donate.t
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.donations.PaymentSourceType
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import java.util.Locale
|
||||
|
||||
object BankTransferMandateRepository {
|
||||
@@ -21,7 +21,7 @@ object BankTransferMandateRepository {
|
||||
}
|
||||
|
||||
return Single
|
||||
.fromCallable { AppDependencies.donationsService.getBankMandate(Locale.getDefault(), sourceString) }
|
||||
.fromCallable { SignalNetwork.donationsService.getBankMandate(Locale.getDefault(), sourceString) }
|
||||
.flatMap { it.flattenResult() }
|
||||
.map { it.mandate }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
+2
-2
@@ -6,13 +6,13 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.getBoostB
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.getGiftBadges
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.getSubscriptionLevels
|
||||
import org.thoughtcrime.securesms.database.model.InAppPaymentReceiptRecord
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import java.util.Locale
|
||||
|
||||
class DonationReceiptListRepository {
|
||||
fun getBadges(): Single<List<DonationReceiptBadge>> {
|
||||
return Single.fromCallable {
|
||||
AppDependencies.donationsService
|
||||
SignalNetwork.donationsService
|
||||
.getDonationsConfiguration(Locale.getDefault())
|
||||
}.map { response ->
|
||||
if (response.result.isPresent) {
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import org.signal.core.util.concurrent.safeBlockingGet
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil
|
||||
@@ -20,7 +21,7 @@ import java.util.concurrent.TimeUnit
|
||||
* Generic repository for interacting with safety numbers and fetch new ones.
|
||||
*/
|
||||
class SafetyNumberRepository(
|
||||
private val profileService: ProfileService = AppDependencies.profileService,
|
||||
private val profileService: ProfileService = SignalNetwork.profileService,
|
||||
private val aciIdentityStore: SignalIdentityKeyStore = AppDependencies.protocolStore.aci().identities()
|
||||
) {
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class DeleteAccountRepository {
|
||||
Log.i(TAG, "deleteAccount: attempting to delete account from server...");
|
||||
|
||||
try {
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.account().deleteAccount());
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.accountApi().deleteAccount());
|
||||
} catch (IOException e) {
|
||||
if (e instanceof NonSuccessfulResponseCodeException && ((NonSuccessfulResponseCodeException) e).code == 4401) {
|
||||
Log.i(TAG, "deleteAccount: WebSocket closed with expected status after delete account, moving forward as delete was successful");
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.signal.network.config.SignalServiceConfiguration
|
||||
import org.signal.network.rest.SignalRestClient
|
||||
import org.signal.network.service.ArchiveService
|
||||
import org.signal.network.service.MessageService
|
||||
import org.signal.network.service.StorageServiceService
|
||||
import org.signal.network.service.UsernameService
|
||||
import org.signal.video.exo.ExoPlayerPool
|
||||
import org.thoughtcrime.securesms.BuildConfig
|
||||
@@ -409,6 +410,9 @@ object AppDependencies {
|
||||
val storageServiceApi: StorageServiceApi
|
||||
get() = networkModule.storageServiceApi
|
||||
|
||||
val storageService: StorageServiceService
|
||||
get() = networkModule.storageService
|
||||
|
||||
val accountApi: AccountApi
|
||||
get() = networkModule.accountApi
|
||||
|
||||
@@ -556,6 +560,7 @@ object AppDependencies {
|
||||
fun provideRegistrationApi(pushServiceSocket: PushServiceSocket): RegistrationApi
|
||||
fun provideRegistrationApiV2(signalRestClient: SignalRestClient): RegistrationApiV2
|
||||
fun provideStorageServiceApi(authWebSocket: SignalWebSocket.AuthenticatedWebSocket, pushServiceSocket: PushServiceSocket): StorageServiceApi
|
||||
fun provideStorageService(storageServiceApi: StorageServiceApi): StorageServiceService
|
||||
fun provideAuthWebSocket(signalServiceConfigurationSupplier: Supplier<SignalServiceConfiguration>, libSignalNetworkSupplier: Supplier<Network>): SignalWebSocket.AuthenticatedWebSocket
|
||||
fun provideUnauthWebSocket(signalServiceConfigurationSupplier: Supplier<SignalServiceConfiguration>, libSignalNetworkSupplier: Supplier<Network>): SignalWebSocket.UnauthenticatedWebSocket
|
||||
fun provideAccountApi(authWebSocket: SignalWebSocket.AuthenticatedWebSocket): AccountApi
|
||||
|
||||
+6
@@ -50,6 +50,7 @@ import org.signal.network.api.UsernameApi;
|
||||
import org.signal.network.rest.SignalRestClient;
|
||||
import org.signal.network.service.ArchiveService;
|
||||
import org.signal.network.service.MessageService;
|
||||
import org.signal.network.service.StorageServiceService;
|
||||
import org.signal.network.service.UsernameService;
|
||||
import org.signal.video.exo.ExoPlayerPool;
|
||||
import org.thoughtcrime.securesms.backup.v2.SignalStoreArchiveCacheStore;
|
||||
@@ -616,6 +617,11 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
return new StorageServiceApi(authWebSocket, pushServiceSocket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull StorageServiceService provideStorageService(@NonNull StorageServiceApi storageServiceApi) {
|
||||
return new StorageServiceService(storageServiceApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull AccountApi provideAccountApi(@NonNull SignalWebSocket.AuthenticatedWebSocket authWebSocket) {
|
||||
return new AccountApi(authWebSocket);
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ package org.thoughtcrime.securesms.dependencies
|
||||
import android.content.Context
|
||||
import org.signal.core.util.billing.BillingDependencies
|
||||
import org.signal.core.util.billing.BillingError
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.internal.push.SubscriptionsConfiguration
|
||||
import java.util.Locale
|
||||
|
||||
@@ -21,7 +22,7 @@ object GooglePlayBillingDependencies : BillingDependencies {
|
||||
override val context: Context get() = AppDependencies.application
|
||||
|
||||
override suspend fun getProductId(): String {
|
||||
val config = AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
val config = SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
|
||||
if (config.result.isPresent) {
|
||||
return config.result.get().backupConfiguration.backupLevelConfigurationMap[SubscriptionsConfiguration.BACKUPS_LEVEL]?.playProductId ?: throw BillingError(BILLING_PRODUCT_ID_NOT_AVAILABLE)
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.signal.network.config.TrustStore
|
||||
import org.signal.network.rest.SignalRestClient
|
||||
import org.signal.network.service.ArchiveService
|
||||
import org.signal.network.service.MessageService
|
||||
import org.signal.network.service.StorageServiceService
|
||||
import org.signal.network.service.UsernameService
|
||||
import org.signal.network.util.Tls12SocketFactory
|
||||
import org.signal.network.util.TlsProxySocketFactory
|
||||
@@ -180,6 +181,8 @@ class NetworkDependenciesModule(
|
||||
provider.provideStorageServiceApi(authWebSocket, pushServiceSocket)
|
||||
}
|
||||
|
||||
val storageService: StorageServiceService by lazy { provider.provideStorageService(storageServiceApi) }
|
||||
|
||||
val accountApi: AccountApi by lazy {
|
||||
provider.provideAccountApi(authWebSocket)
|
||||
}
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobs.protos.ArchiveAttachmentReconciliationJobData
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.logsubmit.SubmitDebugLogActivity
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
import org.thoughtcrime.securesms.notifications.NotificationIds
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
@@ -416,7 +417,7 @@ class ArchiveAttachmentReconciliationJob private constructor(
|
||||
* @return The [ArchiveApiV2.MediaItemsPage] if successful, or null with a [Result] indicating the failure reason.
|
||||
*/
|
||||
private suspend fun getRemoteArchiveItemPage(cursor: String?): Pair<ArchiveApiV2.MediaItemsPage?, Result?> {
|
||||
return when (val result = AppDependencies.archiveService.listRemoteMediaObjects(CDN_FETCH_LIMIT, cursor)) {
|
||||
return when (val result = SignalNetwork.archiveService.listRemoteMediaObjects(CDN_FETCH_LIMIT, cursor)) {
|
||||
is Either.Right -> result.value to null
|
||||
is Either.Left -> when (val error = result.value) {
|
||||
is ArchiveError.NetworkError -> null to Result.retry(defaultBackoff())
|
||||
|
||||
@@ -8,11 +8,11 @@ package org.thoughtcrime.securesms.jobs
|
||||
import arrow.core.Either
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.network.service.ArchiveError
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.CoroutineJob
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
@@ -59,7 +59,7 @@ class ArchiveBackupIdReservationJob private constructor(parameters: Parameters)
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
return when (val result = AppDependencies.archiveService.triggerBackupIdReservation()) {
|
||||
return when (val result = SignalNetwork.archiveService.triggerBackupIdReservation()) {
|
||||
is Either.Right -> Result.success()
|
||||
is Either.Left -> when (val error = result.value) {
|
||||
is ArchiveError.NetworkError -> {
|
||||
|
||||
+2
-2
@@ -16,10 +16,10 @@ import org.thoughtcrime.securesms.backup.v2.ArchivedMediaObject
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.BackupMediaSnapshotTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.CoroutineJob
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.hours
|
||||
@@ -59,7 +59,7 @@ class ArchiveCommitAttachmentDeletesJob private constructor(parameters: Paramete
|
||||
|
||||
val mediaToDelete = chunk.filter { it.cdn == Cdn.CDN_3.cdnNumber }.map { it.toDeleteBackupMediaItem() }
|
||||
|
||||
when (val result = AppDependencies.archiveService.deleteArchivedMedia(mediaToDelete)) {
|
||||
when (val result = SignalNetwork.archiveService.deleteArchivedMedia(mediaToDelete)) {
|
||||
is Either.Right -> {
|
||||
Log.i(tag, "Successfully deleted ${chunk.size} attachments off of the CDN. (Note: Count includes thumbnails)", true)
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
|
||||
val ciphertextLength = AttachmentCipherStreamUtil.getCiphertextLength(PaddingInputStream.getPaddedSize(thumbnailResult.data.size.toLong()))
|
||||
|
||||
val form: AttachmentUploadForm = when (val formResult = AppDependencies.archiveService.getMediaUploadForm(ciphertextLength)) {
|
||||
val form: AttachmentUploadForm = when (val formResult = SignalNetwork.archiveService.getMediaUploadForm(ciphertextLength)) {
|
||||
is Either.Right -> formResult.value
|
||||
is Either.Left -> return when (val error = formResult.value) {
|
||||
is ArchiveError.ApplicationError -> {
|
||||
@@ -249,7 +249,7 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
|
||||
val attachmentPointer = try {
|
||||
val uploadResult: AttachmentUploadResult = buildSignalServiceAttachmentStream(thumbnailResult).use { stream ->
|
||||
when (val result = SignalNetwork.attachments.uploadAttachmentV4(form, key, iv, checksumSha256, stream)) {
|
||||
when (val result = SignalNetwork.attachmentApi.uploadAttachmentV4(form, key, iv, checksumSha256, stream)) {
|
||||
is NetworkResult.Success -> result.result
|
||||
is NetworkResult.ApplicationError -> throw result.throwable
|
||||
is NetworkResult.NetworkError -> throw result.exception
|
||||
@@ -271,7 +271,7 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val copyResult = AppDependencies.archiveService.copyToArchive(
|
||||
val copyResult = SignalNetwork.archiveService.copyToArchive(
|
||||
cdnNumber = attachmentPointer.cdnNumber,
|
||||
remoteLocation = attachmentPointer.remoteLocation,
|
||||
plaintextSize = attachmentPointer.size,
|
||||
|
||||
@@ -178,7 +178,7 @@ class AttachmentUploadJob private constructor(
|
||||
val ciphertextLength = AttachmentCipherStreamUtil.getCiphertextLength(PaddingInputStream.getPaddedSize(databaseAttachment.size))
|
||||
|
||||
val uploadForm = if (existingSpec == null) {
|
||||
when (val result = SignalNetwork.attachments.getAttachmentV4UploadForm(ciphertextLength)) {
|
||||
when (val result = SignalNetwork.attachmentApi.getAttachmentV4UploadForm(ciphertextLength)) {
|
||||
is RequestResult.Success -> result.result
|
||||
is RequestResult.NonSuccess -> throw result.error
|
||||
is RequestResult.RetryableNetworkError -> throw RetryLaterException(result.retryAfter ?: defaultBackoff().milliseconds.toJavaDuration())
|
||||
@@ -201,7 +201,7 @@ class AttachmentUploadJob private constructor(
|
||||
|
||||
getAttachmentNotificationIfNeeded(databaseAttachment).use { notification ->
|
||||
buildAttachmentStream(databaseAttachment, notification).use { localAttachment ->
|
||||
val uploadResult: AttachmentUploadResult = SignalNetwork.attachments.uploadAttachmentV4(
|
||||
val uploadResult: AttachmentUploadResult = SignalNetwork.attachmentApi.uploadAttachmentV4(
|
||||
form = uploadForm,
|
||||
key = key,
|
||||
iv = iv,
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.DeletionNotAwaitingMediaDownlo
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobs.protos.BackupDeleteJobData
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -209,7 +210,7 @@ class BackupDeleteJob private constructor(
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
when (val result = AppDependencies.archiveService.deleteMessageBackup()) {
|
||||
when (val result = SignalNetwork.archiveService.deleteMessageBackup()) {
|
||||
is Either.Right -> Log.d(TAG, "Deleted message backup.")
|
||||
is Either.Left -> {
|
||||
Log.w(TAG, "Failed to delete message backup", result.value.cause)
|
||||
@@ -228,7 +229,7 @@ class BackupDeleteJob private constructor(
|
||||
}
|
||||
|
||||
if (backupDeleteJobData.tier == BackupDeleteJobData.Tier.PAID) {
|
||||
when (val result = AppDependencies.archiveService.deleteMediaBackup()) {
|
||||
when (val result = SignalNetwork.archiveService.deleteMediaBackup()) {
|
||||
is Either.Right -> Log.d(TAG, "Deleted media backup.")
|
||||
is Either.Left -> {
|
||||
Log.w(TAG, "Failed to delete media backup", result.value.cause)
|
||||
|
||||
@@ -233,7 +233,7 @@ class BackupMessagesJob private constructor(
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val auth = when (val result = AppDependencies.archiveService.getSvrBAuth()) {
|
||||
val auth = when (val result = SignalNetwork.archiveService.getSvrBAuth()) {
|
||||
is Either.Right -> result.value
|
||||
is Either.Left -> when (val error = result.value) {
|
||||
is ArchiveError.CredentialError.RateLimited -> {
|
||||
@@ -283,7 +283,7 @@ class BackupMessagesJob private constructor(
|
||||
}
|
||||
|
||||
if (forwardSecrecyMetadata != null) {
|
||||
when (val result = SignalNetwork.svrB.restore(auth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
when (val result = SignalNetwork.svrBApi.restore(auth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
is SvrBApi.RestoreResult.Success -> {
|
||||
Log.i(TAG, "[svrb-restore] Remote secrecy data restored successfully.")
|
||||
SignalStore.backup.nextBackupSecretData = result.data.nextBackupSecretData
|
||||
@@ -322,12 +322,12 @@ class BackupMessagesJob private constructor(
|
||||
|
||||
val backupSecretData = SignalStore.backup.nextBackupSecretData ?: run {
|
||||
Log.i(TAG, "First SVRB backup! Creating new backup chain.", true)
|
||||
val secretData = SignalNetwork.svrB.createNewBackupChain(auth, SignalStore.backup.messageBackupKey)
|
||||
val secretData = SignalNetwork.svrBApi.createNewBackupChain(auth, SignalStore.backup.messageBackupKey)
|
||||
SignalStore.backup.nextBackupSecretData = secretData
|
||||
secretData
|
||||
}
|
||||
|
||||
val svrBMetadata: SvrBStoreResponse = when (val result = SignalNetwork.svrB.store(auth, SignalStore.backup.messageBackupKey, backupSecretData)) {
|
||||
val svrBMetadata: SvrBStoreResponse = when (val result = SignalNetwork.svrBApi.store(auth, SignalStore.backup.messageBackupKey, backupSecretData)) {
|
||||
is SvrBApi.StoreResult.Success -> result.data
|
||||
is SvrBApi.StoreResult.NetworkError -> return Result.retry(result.retryAfter?.inWholeMilliseconds ?: defaultBackoff()).logW(TAG, "SVRB transient network error.", result.exception, true)
|
||||
is SvrBApi.StoreResult.SvrError -> return Result.retry(defaultBackoff()).logW(TAG, "SVRB error.", result.throwable, true)
|
||||
@@ -366,7 +366,7 @@ class BackupMessagesJob private constructor(
|
||||
|
||||
val existingSpec = resumableMessagesBackupUploadSpec
|
||||
val form: AttachmentUploadForm = if (existingSpec == null) {
|
||||
when (val result = AppDependencies.archiveService.getMessageBackupUploadForm(tempBackupFile.length())) {
|
||||
when (val result = SignalNetwork.archiveService.getMessageBackupUploadForm(tempBackupFile.length())) {
|
||||
is Either.Right -> result.value
|
||||
is Either.Left -> when (val error = result.value) {
|
||||
is ArchiveError.NetworkError -> {
|
||||
@@ -421,7 +421,7 @@ class BackupMessagesJob private constructor(
|
||||
}
|
||||
|
||||
val uploadResult = FileInputStream(tempBackupFile).use { fileStream ->
|
||||
SignalNetwork.archive.uploadBackupFile(
|
||||
SignalNetwork.archiveApi.uploadBackupFile(
|
||||
uploadForm = form,
|
||||
data = fileStream,
|
||||
dataLength = tempBackupFile.length(),
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.jobmanager.CoroutineJob
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
@@ -74,7 +75,7 @@ class BackupRefreshJob private constructor(
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
return when (val result = AppDependencies.archiveService.refreshBackup()) {
|
||||
return when (val result = SignalNetwork.archiveService.refreshBackup()) {
|
||||
is Either.Right -> {
|
||||
SignalStore.backup.lastCheckInMillis = System.currentTimeMillis()
|
||||
SignalStore.backup.lastCheckInSnoozeMillis = 0
|
||||
|
||||
@@ -259,7 +259,7 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
||||
if (activeSubscription?.willCancelAtPeriodEnd() == true && activeSubscription.activeSubscription != null) {
|
||||
Log.i(TAG, "Subscription either has a payment failure or has been canceled.")
|
||||
|
||||
val response = SignalNetwork.account.whoAmI()
|
||||
val response = SignalNetwork.accountApi.whoAmI()
|
||||
response.runIfSuccessful { whoAmI ->
|
||||
val backupExpiration = whoAmI.entitlements?.backup?.expirationSeconds?.seconds
|
||||
if (backupExpiration != null) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class BuildExpirationConfirmationJob private constructor(params: Parameters) : J
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
return when (val result: NetworkResult<RemoteConfigResult> = SignalNetwork.remoteConfig.getRemoteConfig()) {
|
||||
return when (val result: NetworkResult<RemoteConfigResult> = SignalNetwork.remoteConfigApi.getRemoteConfig()) {
|
||||
is NetworkResult.Success -> {
|
||||
val serverTimeMs = result.result.serverEpochTimeMilliseconds
|
||||
SignalStore.misc.setLastKnownServerTime(serverTimeMs, System.currentTimeMillis())
|
||||
|
||||
@@ -128,7 +128,7 @@ class CheckKeyTransparencyJob private constructor(
|
||||
|
||||
val recipient = SignalDatabase.recipients.getRecord(Recipient.self().id)
|
||||
|
||||
val result = SignalNetwork.keyTransparency.check(
|
||||
val result = SignalNetwork.keyTransparencyApi.check(
|
||||
checkMode = CheckMode.Self(isE164Discoverable = SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode == PhoneNumberDiscoverabilityMode.DISCOVERABLE),
|
||||
aci = recipient.aci!!.libSignalAci,
|
||||
aciIdentityKey = SignalStore.account.aciIdentityKey.publicKey,
|
||||
|
||||
@@ -101,7 +101,7 @@ public class FcmRefreshJob extends BaseJob {
|
||||
Log.i(TAG, "Token didn't change.");
|
||||
}
|
||||
|
||||
RequestResultUtil.successOrThrowNoError(SignalNetwork.account().setFcmToken(token.get()));
|
||||
RequestResultUtil.successOrThrowNoError(SignalNetwork.accountApi().setFcmToken(token.get()));
|
||||
SignalStore.account().setFcmToken(token.get());
|
||||
|
||||
if (!SignalStore.account().isFcmEnabled()) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.subscription.LevelUpdate
|
||||
import org.thoughtcrime.securesms.subscription.LevelUpdateOperation
|
||||
import org.thoughtcrime.securesms.util.Environment
|
||||
@@ -210,9 +211,9 @@ class InAppPaymentAuthCheckJob private constructor(parameters: Parameters) : Bas
|
||||
|
||||
Log.i(TAG, "Setting default payment method...", true)
|
||||
val setPaymentMethodResponse = if (inAppPayment.data.paymentMethodType == InAppPaymentData.PaymentMethodType.IDEAL) {
|
||||
AppDependencies.donationsService.setDefaultIdealPaymentMethod(subscriber.subscriberId, stripeSetupIntent.id)
|
||||
SignalNetwork.donationsService.setDefaultIdealPaymentMethod(subscriber.subscriberId, stripeSetupIntent.id)
|
||||
} else {
|
||||
AppDependencies.donationsService.setDefaultStripePaymentMethod(subscriber.subscriberId, stripeSetupIntent.paymentMethodId)
|
||||
SignalNetwork.donationsService.setDefaultStripePaymentMethod(subscriber.subscriberId, stripeSetupIntent.paymentMethodId)
|
||||
}
|
||||
|
||||
when (val result = checkResult(setPaymentMethodResponse)) {
|
||||
@@ -233,7 +234,7 @@ class InAppPaymentAuthCheckJob private constructor(parameters: Parameters) : Bas
|
||||
val updateOperation: LevelUpdateOperation = RecurringInAppPaymentRepository.getOrCreateLevelUpdateOperation(TAG, level)
|
||||
Log.d(TAG, "Attempting to set user subscription level to $level", true)
|
||||
|
||||
val updateLevelResponse = AppDependencies.donationsService.updateSubscriptionLevel(
|
||||
val updateLevelResponse = SignalNetwork.donationsService.updateSubscriptionLevel(
|
||||
subscriber.subscriberId,
|
||||
level,
|
||||
subscriber.currency!!.currencyCode,
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription
|
||||
import org.whispersystems.signalservice.internal.EmptyResponse
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse
|
||||
@@ -131,12 +132,12 @@ class InAppPaymentKeepAliveJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val response: ServiceResponse<EmptyResponse> = AppDependencies.donationsService.putSubscription(subscriber.subscriberId)
|
||||
val response: ServiceResponse<EmptyResponse> = SignalNetwork.donationsService.putSubscription(subscriber.subscriberId)
|
||||
|
||||
verifyResponse(response)
|
||||
info(type, "Successful call to putSubscription")
|
||||
|
||||
val activeSubscriptionResponse: ServiceResponse<ActiveSubscription> = AppDependencies.donationsService.getSubscription(subscriber.subscriberId)
|
||||
val activeSubscriptionResponse: ServiceResponse<ActiveSubscription> = SignalNetwork.donationsService.getSubscription(subscriber.subscriberId)
|
||||
|
||||
verifyResponse(activeSubscriptionResponse)
|
||||
info(type, "Successful call to GET active subscription")
|
||||
@@ -292,7 +293,7 @@ class InAppPaymentKeepAliveJob private constructor(
|
||||
|
||||
val badge = if (oldInAppPayment == null) {
|
||||
info(type, "Old payment not found in database. Loading badge / label information from donations configuration.")
|
||||
val configuration = AppDependencies.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
val configuration = SignalNetwork.donationsService.getDonationsConfiguration(Locale.getDefault())
|
||||
if (configuration.result.isPresent) {
|
||||
val subscriptionConfig = configuration.result.get().levels[subscription.level]
|
||||
if (subscriptionConfig == null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager.Chain
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse
|
||||
import org.whispersystems.signalservice.internal.push.exceptions.InAppPaymentReceiptCredentialError
|
||||
import java.io.IOException
|
||||
@@ -123,7 +124,7 @@ class InAppPaymentOneTimeContextJob private constructor(
|
||||
val (inAppPayment, requestContext) = getAndValidateInAppPayment()
|
||||
|
||||
info("Submitting request context to server...")
|
||||
val serviceResponse = AppDependencies.donationsService.submitBoostReceiptCredentialRequestSync(
|
||||
val serviceResponse = SignalNetwork.donationsService.submitBoostReceiptCredentialRequestSync(
|
||||
inAppPayment.data.redemption!!.paymentIntentId,
|
||||
requestContext.request,
|
||||
inAppPayment.data.paymentMethodType.toDonationProcessor()
|
||||
|
||||
+2
-2
@@ -12,9 +12,9 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.OneTimeIn
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.PayPalRepository
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.donate.paypal.PayPalConfirmationResult
|
||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.protos.InAppPaymentSetupJobData
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.whispersystems.signalservice.api.subscriptions.PayPalCreatePaymentIntentResponse
|
||||
@@ -40,7 +40,7 @@ class InAppPaymentPayPalOneTimeSetupJob private constructor(data: InAppPaymentSe
|
||||
}
|
||||
}
|
||||
|
||||
private val payPalRepository = PayPalRepository(AppDependencies.donationsService)
|
||||
private val payPalRepository = PayPalRepository(SignalNetwork.donationsService)
|
||||
|
||||
override fun performPreUserAction(inAppPayment: InAppPaymentTable.InAppPayment): RequiredUserAction {
|
||||
info("Beginning one-time payment pipeline.")
|
||||
|
||||
+2
-2
@@ -12,9 +12,9 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaym
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.PayPalRepository
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.RecurringInAppPaymentRepository
|
||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.protos.InAppPaymentSetupJobData
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
|
||||
class InAppPaymentPayPalRecurringSetupJob private constructor(data: InAppPaymentSetupJobData, parameters: Parameters) : InAppPaymentSetupJob(data, parameters) {
|
||||
|
||||
@@ -37,7 +37,7 @@ class InAppPaymentPayPalRecurringSetupJob private constructor(data: InAppPayment
|
||||
}
|
||||
}
|
||||
|
||||
private val payPalRepository = PayPalRepository(AppDependencies.donationsService)
|
||||
private val payPalRepository = PayPalRepository(SignalNetwork.donationsService)
|
||||
|
||||
override fun performPreUserAction(inAppPayment: InAppPaymentTable.InAppPayment): RequiredUserAction {
|
||||
info("Ensuring the subscriber id is set on the server.")
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager.Chain
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.storage.IAPSubscriptionId
|
||||
import kotlin.concurrent.withLock
|
||||
import kotlin.time.Duration.Companion.days
|
||||
@@ -113,7 +114,7 @@ class InAppPaymentPurchaseTokenJob private constructor(
|
||||
info("Attempting to link purchase token for purchase")
|
||||
info("$purchase")
|
||||
|
||||
val response = AppDependencies.donationsService.linkGooglePlayBillingPurchaseTokenToSubscriberId(
|
||||
val response = SignalNetwork.donationsService.linkGooglePlayBillingPurchaseTokenToSubscriberId(
|
||||
inAppPayment.subscriberId!!,
|
||||
purchase.purchaseToken,
|
||||
InAppPaymentSubscriberRecord.Type.BACKUP.lock
|
||||
|
||||
+3
-2
@@ -30,6 +30,7 @@ import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager.Chain
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription.ChargeFailure
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription.Subscription
|
||||
@@ -343,7 +344,7 @@ class InAppPaymentRecurringContextJob private constructor(
|
||||
}
|
||||
|
||||
private fun getActiveSubscription(inAppPayment: InAppPaymentTable.InAppPayment): ActiveSubscription {
|
||||
val activeSubscriptionResponse = AppDependencies.donationsService.getSubscription(inAppPayment.subscriberId)
|
||||
val activeSubscriptionResponse = SignalNetwork.donationsService.getSubscription(inAppPayment.subscriberId)
|
||||
return if (activeSubscriptionResponse.result.isPresent) {
|
||||
activeSubscriptionResponse.result.get()
|
||||
} else if (activeSubscriptionResponse.applicationError.isPresent) {
|
||||
@@ -497,7 +498,7 @@ class InAppPaymentRecurringContextJob private constructor(
|
||||
requestContext: ReceiptCredentialRequestContext
|
||||
) {
|
||||
info("Submitting receipt credential request")
|
||||
val response: ServiceResponse<ReceiptCredentialResponse> = AppDependencies.donationsService.submitReceiptCredentialRequestSync(inAppPayment.subscriberId!!, requestContext.request)
|
||||
val response: ServiceResponse<ReceiptCredentialResponse> = SignalNetwork.donationsService.submitReceiptCredentialRequestSync(inAppPayment.subscriberId!!, requestContext.request)
|
||||
|
||||
if (response.applicationError.isPresent) {
|
||||
handleApplicationError(inAppPayment, response)
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SealedSenderConstraint
|
||||
import org.thoughtcrime.securesms.jobs.protos.IndividualSendJobV2Data
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.ratelimit.ProofRequiredExceptionHandler
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil
|
||||
@@ -410,7 +411,7 @@ class IndividualSendJobV2 private constructor(parameters: Parameters, private va
|
||||
return MessageService.SendSuccess(envelopeContent, true, listOf(SignalServiceAddress.DEFAULT_DEVICE_ID))
|
||||
}
|
||||
|
||||
return AppDependencies.messageService.sendMessage(
|
||||
return SignalNetwork.messageService.sendMessage(
|
||||
serviceId = recipient.requireServiceId(),
|
||||
envelopeContent = envelopeContent,
|
||||
timestamp = dataMessage.timestamp!!,
|
||||
@@ -458,7 +459,7 @@ class IndividualSendJobV2 private constructor(parameters: Parameters, private va
|
||||
)
|
||||
val syncEnvelope = EnvelopeContent.encrypted(syncContent, ContentHint.IMPLICIT, Optional.empty())
|
||||
|
||||
return AppDependencies.messageService.sendSyncMessage(
|
||||
return SignalNetwork.messageService.sendSyncMessage(
|
||||
envelopeContent = syncEnvelope,
|
||||
timestamp = timestamp,
|
||||
urgent = true,
|
||||
|
||||
@@ -185,7 +185,7 @@ class PreKeysSyncJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val availablePreKeyCounts = SignalNetwork.keys.getAvailablePreKeyCountsSync(serviceIdType).successOrThrow()
|
||||
val availablePreKeyCounts = SignalNetwork.keysApi.getAvailablePreKeyCountsSync(serviceIdType).successOrThrow()
|
||||
|
||||
val signedPreKeyToUpload: SignedPreKeyRecord? = signedPreKeyUploadIfNeeded(serviceIdType, protocolStore, metadataStore, forceRotation)
|
||||
|
||||
@@ -209,7 +209,7 @@ class PreKeysSyncJob private constructor(
|
||||
|
||||
if (signedPreKeyToUpload != null || oneTimeEcPreKeysToUpload != null || lastResortKyberPreKeyToUpload != null || oneTimeKyberPreKeysToUpload != null) {
|
||||
log(serviceIdType, "Something to upload. SignedPreKey: ${signedPreKeyToUpload != null}, OneTimeEcPreKeys: ${oneTimeEcPreKeysToUpload != null}, LastResortKyberPreKey: ${lastResortKyberPreKeyToUpload != null}, OneTimeKyberPreKeys: ${oneTimeKyberPreKeysToUpload != null}")
|
||||
SignalNetwork.keys.setPreKeysSync(
|
||||
SignalNetwork.keysApi.setPreKeysSync(
|
||||
PreKeyUpload(
|
||||
serviceIdType = serviceIdType,
|
||||
signedPreKey = signedPreKeyToUpload,
|
||||
@@ -278,7 +278,7 @@ class PreKeysSyncJob private constructor(
|
||||
@Throws(IOException::class)
|
||||
private fun checkPreKeyConsistency(serviceIdType: ServiceIdType, protocolStore: SignalServiceAccountDataStore, metadataStore: PreKeyMetadataStore): Boolean {
|
||||
val result: NetworkResult<Unit> = try {
|
||||
SignalNetwork.keys.checkRepeatedUseKeysSync(
|
||||
SignalNetwork.keysApi.checkRepeatedUseKeysSync(
|
||||
serviceIdType = serviceIdType,
|
||||
identityKey = protocolStore.identityKeyPair.publicKey,
|
||||
signedPreKeyId = metadataStore.activeSignedPreKeyId,
|
||||
|
||||
@@ -110,8 +110,8 @@ public class RefreshAttributesJob extends BaseJob {
|
||||
} else {
|
||||
boolean phoneNumberDiscoverable = !SignalStore.account().isPhoneNumberless() && SignalStore.phoneNumberPrivacy().getPhoneNumberDiscoverabilityMode() == PhoneNumberDiscoverabilityMode.DISCOVERABLE;
|
||||
Log.i(TAG, "Linked device, refreshing device capabilities and phone number discoverability. Capabilities: " + capabilities + ", discoverable: " + phoneNumberDiscoverable);
|
||||
RequestResultUtil.successOrThrow(SignalNetwork.account().setCapabilities(capabilities));
|
||||
RequestResultUtil.successOrThrowNoError(SignalNetwork.account().setPhoneNumberDiscoverability(phoneNumberDiscoverable));
|
||||
RequestResultUtil.successOrThrow(SignalNetwork.accountApi().setCapabilities(capabilities));
|
||||
RequestResultUtil.successOrThrowNoError(SignalNetwork.accountApi().setPhoneNumberDiscoverability(phoneNumberDiscoverable));
|
||||
}
|
||||
|
||||
hasRefreshedThisAppCycle = true;
|
||||
@@ -155,7 +155,7 @@ public class RefreshAttributesJob extends BaseJob {
|
||||
recoveryPassword
|
||||
);
|
||||
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.account().setAccountAttributes(accountAttributes));
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.accountApi().setAccountAttributes(accountAttributes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.NotPushRegisteredException
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ class RefreshDonationSubscriptionStatusJob private constructor(parameters: Param
|
||||
return
|
||||
}
|
||||
|
||||
val activeSubscription = AppDependencies.donationsService.getSubscription(subscriber.subscriberId).resultOrThrow
|
||||
val activeSubscription = SignalNetwork.donationsService.getSubscription(subscriber.subscriberId).resultOrThrow
|
||||
|
||||
if (activeSubscription.isActive) {
|
||||
val endOfCurrentPeriod = activeSubscription.activeSubscription.endOfCurrentPeriod
|
||||
|
||||
@@ -315,7 +315,7 @@ class RefreshOwnProfileJob private constructor(parameters: Parameters) : BaseJob
|
||||
|
||||
var isDueToPaymentFailure = false
|
||||
if (subscriber != null) {
|
||||
val response = AppDependencies.donationsService
|
||||
val response = SignalNetwork.donationsService
|
||||
.getSubscription(subscriber.subscriberId)
|
||||
|
||||
if (response.getResult().isPresent()) {
|
||||
@@ -439,7 +439,7 @@ class RefreshOwnProfileJob private constructor(parameters: Parameters) : BaseJob
|
||||
|
||||
val localUsernameLink = SignalStore.account.usernameLink ?: return
|
||||
|
||||
when (val usernameFetchResult = SignalNetwork.username.getDecryptedUsernameFromLinkServerIdAndEntropy(localUsernameLink.serverId, localUsernameLink.entropy)) {
|
||||
when (val usernameFetchResult = SignalNetwork.usernameApi.getDecryptedUsernameFromLinkServerIdAndEntropy(localUsernameLink.serverId, localUsernameLink.entropy)) {
|
||||
is RequestResult.Success -> {
|
||||
val remoteUsername = usernameFetchResult.result
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class RemoteConfigRefreshJob private constructor(parameters: Parameters) : Job(p
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
return when (val result = SignalNetwork.remoteConfig.getRemoteConfig(SignalStore.remoteConfig.eTag)) {
|
||||
return when (val result = SignalNetwork.remoteConfigApi.getRemoteConfig(SignalStore.remoteConfig.eTag)) {
|
||||
is NetworkResult.Success -> {
|
||||
RemoteConfig.update(result.result.config)
|
||||
SignalStore.misc.setLastKnownServerTime(result.result.serverEpochTimeMilliseconds, System.currentTimeMillis())
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ReportSpamJob extends BaseJob {
|
||||
reportingTokenEncoded = Base64.encodeWithPadding(reportingTokenBytes);
|
||||
}
|
||||
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.message().reportSpam(serviceId, data.getServerGuid(), reportingTokenEncoded));
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.messageApi().reportSpam(serviceId, data.getServerGuid(), reportingTokenEncoded));
|
||||
count++;
|
||||
} else {
|
||||
Log.w(TAG, "Unable to report spam without an ACI for " + recipientId);
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.logsubmit.SubmitDebugLogActivity
|
||||
import org.thoughtcrime.securesms.mms.MmsException
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
import org.thoughtcrime.securesms.notifications.NotificationIds
|
||||
import org.thoughtcrime.securesms.service.BackupMediaRestoreService
|
||||
@@ -382,7 +383,7 @@ class RestoreAttachmentJob private constructor(
|
||||
|
||||
ArchiveRestoreProgress.onDownloadStart(attachmentId)
|
||||
val decryptingStream = if (useArchiveCdn) {
|
||||
val cdnCredentials = runBlocking { AppDependencies.archiveService.getCdnReadCredentials(ArchiveService.CredentialType.MEDIA, pointer.cdnNumber) }.successOrThrow().headers
|
||||
val cdnCredentials = runBlocking { SignalNetwork.archiveService.getCdnReadCredentials(ArchiveService.CredentialType.MEDIA, pointer.cdnNumber) }.successOrThrow().headers
|
||||
|
||||
messageReceiver
|
||||
.retrieveArchivedAttachment(
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.thoughtcrime.securesms.jobmanager.JobLogger.format
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.messages.AttachmentTransferProgress
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment
|
||||
@@ -130,7 +131,7 @@ class RestoreAttachmentThumbnailJob private constructor(
|
||||
override fun shouldCancel(): Boolean = this@RestoreAttachmentThumbnailJob.isCanceled
|
||||
}
|
||||
|
||||
val cdnCredentials = runBlocking { AppDependencies.archiveService.getCdnReadCredentials(ArchiveService.CredentialType.MEDIA, attachment.archiveCdn ?: RemoteConfig.backupFallbackArchiveCdn) }.successOrThrow().headers
|
||||
val cdnCredentials = runBlocking { SignalNetwork.archiveService.getCdnReadCredentials(ArchiveService.CredentialType.MEDIA, attachment.archiveCdn ?: RemoteConfig.backupFallbackArchiveCdn) }.successOrThrow().headers
|
||||
val pointer = attachment.createArchiveThumbnailPointer()
|
||||
|
||||
Log.i(TAG, "Downloading thumbnail for $attachmentId")
|
||||
|
||||
@@ -132,7 +132,7 @@ class RetrieveProfileJob private constructor(parameters: Parameters, private val
|
||||
|
||||
val response: ProfileFetchResult<RecipientId> = runBlocking {
|
||||
withContext(Dispatchers.IO) {
|
||||
ProfileRepository(SignalNetwork.profile).fetchProfiles(requests)
|
||||
ProfileRepository(SignalNetwork.profileApi).fetchProfiles(requests)
|
||||
}
|
||||
}
|
||||
stopwatch.split("responses")
|
||||
|
||||
@@ -76,8 +76,8 @@ public final class RotateCertificateJob extends BaseJob {
|
||||
|
||||
try {
|
||||
switch (certificateType) {
|
||||
case ACI_AND_E164: certificate = NetworkResultUtil.toBasicLegacy(SignalNetwork.certificate().getSenderCertificate()); break;
|
||||
case ACI_ONLY : certificate = NetworkResultUtil.toBasicLegacy(SignalNetwork.certificate().getSenderCertificateForPhoneNumberPrivacy()); break;
|
||||
case ACI_AND_E164: certificate = NetworkResultUtil.toBasicLegacy(SignalNetwork.certificateApi().getSenderCertificate()); break;
|
||||
case ACI_ONLY : certificate = NetworkResultUtil.toBasicLegacy(SignalNetwork.certificateApi().getSenderCertificateForPhoneNumberPrivacy()); break;
|
||||
default : throw new AssertionError();
|
||||
}
|
||||
} catch (NonSuccessfulResponseCodeException e) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class StorageAccountRestoreJob private constructor(parameters: Parameters) : Bas
|
||||
SignalStore.storageService.storageKey
|
||||
}
|
||||
|
||||
val repository = StorageServiceService(SignalNetwork.storageService)
|
||||
val repository = SignalNetwork.storageService
|
||||
|
||||
Log.i(TAG, "Retrieving manifest...")
|
||||
val manifest: SignalStorageManifest? = when (val result = repository.getStorageManifest(storageServiceKey)) {
|
||||
|
||||
@@ -12,10 +12,10 @@ import org.thoughtcrime.securesms.database.NotificationProfileTables
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.StickerPackId
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfileId
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
@@ -72,7 +72,7 @@ class StorageForcePushJob private constructor(parameters: Parameters) : BaseJob(
|
||||
}
|
||||
|
||||
val storageServiceKey = SignalStore.storageService.storageKey
|
||||
val repository = StorageServiceService(AppDependencies.storageServiceApi)
|
||||
val repository = SignalNetwork.storageService
|
||||
|
||||
val currentVersion: Long = when (val result = repository.getManifestVersion()) {
|
||||
is NetworkResult.Success -> result.result
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageManifest
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -52,7 +53,7 @@ class StorageRotateManifestJob private constructor(parameters: Parameters) : Job
|
||||
}
|
||||
|
||||
val storageServiceKey = SignalStore.storageService.storageKey
|
||||
val repository = StorageServiceService(AppDependencies.storageServiceApi)
|
||||
val repository = SignalNetwork.storageService
|
||||
|
||||
val currentManifest: SignalStorageManifest = when (val result = repository.getStorageManifest(restoreKey)) {
|
||||
is StorageServiceService.ManifestResult.Success -> {
|
||||
|
||||
@@ -258,7 +258,7 @@ class StorageSyncJob private constructor(parameters: Parameters, private var loc
|
||||
private fun performSync(storageServiceKey: StorageKey): Boolean {
|
||||
val stopwatch = Stopwatch("StorageSync")
|
||||
val db = SignalDatabase.writableDatabase
|
||||
val repository = StorageServiceService(SignalNetwork.storageService)
|
||||
val repository = SignalNetwork.storageService
|
||||
|
||||
val localManifest = SignalStore.storageService.manifest
|
||||
val fetchRemoteManifest = localManifestOutOfDate || localManifest.version < 1 || runAttempt >= 3
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public final class SubmitRateLimitPushChallengeJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
protected void onRun() throws Exception {
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.rateLimitChallenge().submitPushChallenge(challenge));
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.rateLimitChallengeApi().submitPushChallenge(challenge));
|
||||
SignalStore.rateLimit().onProofAccepted();
|
||||
EventBus.getDefault().post(new SuccessEvent());
|
||||
RateLimitUtil.retryAllRateLimitedMessages(context);
|
||||
|
||||
@@ -231,7 +231,7 @@ class UploadAttachmentToArchiveJob private constructor(
|
||||
val ciphertextLength = AttachmentCipherStreamUtil.getCiphertextLength(PaddingInputStream.getPaddedSize(attachment.size))
|
||||
|
||||
val form: AttachmentUploadForm? = if (existingSpec == null) {
|
||||
when (val formResult = AppDependencies.archiveService.getMediaUploadForm(ciphertextLength)) {
|
||||
when (val formResult = SignalNetwork.archiveService.getMediaUploadForm(ciphertextLength)) {
|
||||
is Either.Right -> formResult.value
|
||||
is Either.Left -> return when (val error = formResult.value) {
|
||||
is ArchiveError.ApplicationError -> {
|
||||
@@ -314,7 +314,7 @@ class UploadAttachmentToArchiveJob private constructor(
|
||||
progressServiceController.use {
|
||||
val uploadResult: AttachmentUploadResult = attachmentStream.use { stream ->
|
||||
when (
|
||||
val result = SignalNetwork.attachments.uploadAttachmentV4(
|
||||
val result = SignalNetwork.attachmentApi.uploadAttachmentV4(
|
||||
form = form,
|
||||
key = key,
|
||||
iv = iv,
|
||||
|
||||
@@ -213,7 +213,7 @@ object LinkDeviceRepository {
|
||||
return LinkDeviceResult.BadCode
|
||||
}
|
||||
|
||||
val verificationCodeResult: LinkedDeviceVerificationCodeResponse = when (val result = SignalNetwork.linkDevice.getDeviceVerificationCode()) {
|
||||
val verificationCodeResult: LinkedDeviceVerificationCodeResponse = when (val result = SignalNetwork.linkDeviceApi.getDeviceVerificationCode()) {
|
||||
is NetworkResult.Success -> result.result
|
||||
is NetworkResult.ApplicationError -> throw result.throwable
|
||||
is NetworkResult.NetworkError -> return LinkDeviceResult.NetworkError(result.exception)
|
||||
@@ -234,7 +234,7 @@ object LinkDeviceRepository {
|
||||
return LinkDeviceResult.KeyError
|
||||
}
|
||||
|
||||
val deviceLinkResult = SignalNetwork.linkDevice.linkDevice(
|
||||
val deviceLinkResult = SignalNetwork.linkDeviceApi.linkDevice(
|
||||
e164 = SignalStore.account.e164,
|
||||
aci = SignalStore.account.aci!!,
|
||||
pni = SignalStore.account.pni,
|
||||
@@ -284,7 +284,7 @@ object LinkDeviceRepository {
|
||||
|
||||
while (timeRemaining > 0) {
|
||||
Log.d(TAG, "[waitForDeviceToBeLinked] Willing to wait for $timeRemaining ms...")
|
||||
val result = SignalNetwork.linkDevice.waitForLinkedDevice(
|
||||
val result = SignalNetwork.linkDeviceApi.waitForLinkedDevice(
|
||||
token = token,
|
||||
timeout = timeRemaining.milliseconds
|
||||
)
|
||||
@@ -403,7 +403,7 @@ object LinkDeviceRepository {
|
||||
|
||||
Log.d(TAG, "[createAndUploadArchive] Setting the transfer archive...")
|
||||
val transferSetResult = NetworkResult.withRetry {
|
||||
SignalNetwork.linkDevice.setTransferArchive(
|
||||
SignalNetwork.linkDeviceApi.setTransferArchive(
|
||||
destinationDeviceId = deviceId,
|
||||
destinationDeviceRegistrationId = deviceRegistrationId,
|
||||
cdn = uploadedForm.cdn,
|
||||
@@ -444,7 +444,7 @@ object LinkDeviceRepository {
|
||||
return NetworkResult.withRetry(
|
||||
logAttempt = { attempt, maxAttempts -> Log.i(TAG, "Starting upload attempt ${attempt + 1}/$maxAttempts") }
|
||||
) {
|
||||
val form = uploadForm ?: when (val result = SignalNetwork.attachments.getAttachmentV4UploadForm(backupFile.length())) {
|
||||
val form = uploadForm ?: when (val result = SignalNetwork.attachmentApi.getAttachmentV4UploadForm(backupFile.length())) {
|
||||
is RequestResult.Success -> result.result.also { uploadForm = it }
|
||||
is RequestResult.RetryableNetworkError -> return@withRetry NetworkResult.NetworkError<Unit>(result.networkError)
|
||||
is RequestResult.NonSuccess -> return@withRetry NetworkResult.NetworkError<Unit>(result.error)
|
||||
@@ -452,7 +452,7 @@ object LinkDeviceRepository {
|
||||
}
|
||||
|
||||
FileInputStream(backupFile).use {
|
||||
SignalNetwork.archive.uploadBackupFile(
|
||||
SignalNetwork.archiveApi.uploadBackupFile(
|
||||
uploadForm = form,
|
||||
data = it,
|
||||
dataLength = backupFile.length(),
|
||||
@@ -474,7 +474,7 @@ object LinkDeviceRepository {
|
||||
* If [createAndUploadArchive] is cancelled or fails to upload an archive, alert the linked device of the failure and if the user will try again
|
||||
*/
|
||||
fun sendTransferArchiveError(deviceId: Int, deviceRegistrationId: Int, error: TransferArchiveError) {
|
||||
val archiveErrorResult = SignalNetwork.linkDevice.setTransferArchiveError(
|
||||
val archiveErrorResult = SignalNetwork.linkDeviceApi.setTransferArchiveError(
|
||||
destinationDeviceId = deviceId,
|
||||
destinationDeviceRegistrationId = deviceRegistrationId,
|
||||
error = error
|
||||
@@ -493,7 +493,7 @@ object LinkDeviceRepository {
|
||||
*/
|
||||
suspend fun changeDeviceName(deviceName: String, deviceId: Int): DeviceNameChangeResult {
|
||||
val encryptedDeviceName = DeviceNameCipher.encryptDeviceName(deviceName.toByteArray(StandardCharsets.UTF_8), SignalStore.account.aciIdentityKey)
|
||||
return when (val result = SignalNetwork.linkDevice.setDeviceName(encryptedDeviceName, deviceId)) {
|
||||
return when (val result = SignalNetwork.linkDeviceApi.setDeviceName(encryptedDeviceName, deviceId)) {
|
||||
is RequestResult.Success -> {
|
||||
AppDependencies.jobManager.add(DeviceNameChangeJob(deviceId))
|
||||
DeviceNameChangeResult.Success.logI(TAG, "Successfully changed device name")
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ internal class FixChangeNumberErrorMigrationJob(
|
||||
return
|
||||
}
|
||||
|
||||
when (val result = SignalNetwork.account.whoAmI()) {
|
||||
when (val result = SignalNetwork.accountApi.whoAmI()) {
|
||||
is NetworkResult.Success<WhoAmIResponse> -> {
|
||||
val serverPni = result.result.pni?.let { ServiceId.PNI.parseOrNull(it) } ?: return
|
||||
val serverE164 = result.result.number
|
||||
@@ -94,7 +94,7 @@ internal class FixChangeNumberErrorMigrationJob(
|
||||
return false
|
||||
}
|
||||
|
||||
val serverIdentityKey: IdentityKey = when (val profileResult = runBlocking { SignalNetwork.profile.getUnversionedProfile(pni, null) }) {
|
||||
val serverIdentityKey: IdentityKey = when (val profileResult = runBlocking { SignalNetwork.profileApi.getUnversionedProfile(pni, null) }) {
|
||||
is NetworkResult.Success -> {
|
||||
val identityKey = profileResult.result.identityKey
|
||||
if (identityKey == null) {
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class PniAccountInitializationMigrationJob extends MigrationJob {
|
||||
SignedPreKeyRecord signedPreKey = PreKeyUtil.generateAndStoreSignedPreKey(protocolStore, metadataStore);
|
||||
List<PreKeyRecord> oneTimePreKeys = PreKeyUtil.generateAndStoreOneTimeEcPreKeys(protocolStore, metadataStore);
|
||||
|
||||
NetworkResultUtil.toPreKeysLegacy(SignalNetwork.keys().setPreKeysSync(new PreKeyUpload(ServiceIdType.PNI, signedPreKey, oneTimePreKeys, null, null)));
|
||||
NetworkResultUtil.toPreKeysLegacy(SignalNetwork.keysApi().setPreKeysSync(new PreKeyUpload(ServiceIdType.PNI, signedPreKey, oneTimePreKeys, null, null)));
|
||||
metadataStore.setActiveSignedPreKeyId(signedPreKey.getId());
|
||||
metadataStore.setSignedPreKeyRegistered(true);
|
||||
} else {
|
||||
|
||||
@@ -19,12 +19,18 @@ import org.signal.network.api.RateLimitChallengeApi
|
||||
import org.signal.network.api.RemoteConfigApi
|
||||
import org.signal.network.api.SvrBApi
|
||||
import org.signal.network.api.UsernameApi
|
||||
import org.signal.network.service.ArchiveService
|
||||
import org.signal.network.service.MessageService
|
||||
import org.signal.network.service.StorageServiceService
|
||||
import org.signal.network.service.UsernameService
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.dependencies.KeyTransparencyApi
|
||||
import org.whispersystems.signalservice.api.account.AccountApi
|
||||
import org.whispersystems.signalservice.api.keys.KeysApi
|
||||
import org.whispersystems.signalservice.api.message.MessageApi
|
||||
import org.whispersystems.signalservice.api.profiles.ProfileApi
|
||||
import org.whispersystems.signalservice.api.services.DonationsService
|
||||
import org.whispersystems.signalservice.api.services.ProfileService
|
||||
import org.whispersystems.signalservice.api.storage.StorageServiceApi
|
||||
|
||||
/**
|
||||
@@ -34,66 +40,84 @@ import org.whispersystems.signalservice.api.storage.StorageServiceApi
|
||||
*/
|
||||
open class SignalNetwork {
|
||||
|
||||
open val account: AccountApi
|
||||
open val accountApi: AccountApi
|
||||
get() = AppDependencies.accountApi
|
||||
|
||||
open val accountV2: AccountApiV2
|
||||
open val accountApiV2: AccountApiV2
|
||||
get() = AppDependencies.accountApiV2
|
||||
|
||||
open val archive: ArchiveApi
|
||||
open val archiveApi: ArchiveApi
|
||||
get() = AppDependencies.archiveApi
|
||||
|
||||
open val archiveV2: ArchiveApiV2
|
||||
open val archiveApiV2: ArchiveApiV2
|
||||
get() = AppDependencies.archiveApiV2
|
||||
|
||||
open val attachments: AttachmentApi
|
||||
open val attachmentApi: AttachmentApi
|
||||
get() = AppDependencies.attachmentApi
|
||||
|
||||
open val calling: CallingApi
|
||||
open val callingApi: CallingApi
|
||||
get() = AppDependencies.callingApi
|
||||
|
||||
open val cdsApi: CdsApi
|
||||
get() = AppDependencies.cdsApi
|
||||
|
||||
open val certificate: CertificateApi
|
||||
open val certificateApi: CertificateApi
|
||||
get() = AppDependencies.certificateApi
|
||||
|
||||
open val keys: KeysApi
|
||||
open val keysApi: KeysApi
|
||||
get() = AppDependencies.keysApi
|
||||
|
||||
open val keyTransparency: KeyTransparencyApi
|
||||
open val keyTransparencyApi: KeyTransparencyApi
|
||||
get() = AppDependencies.keyTransparencyApi
|
||||
|
||||
open val linkDevice: LinkDeviceApi
|
||||
open val linkDeviceApi: LinkDeviceApi
|
||||
get() = AppDependencies.linkDeviceApi
|
||||
|
||||
open val message: MessageApi
|
||||
open val messageApi: MessageApi
|
||||
get() = AppDependencies.messageApi
|
||||
|
||||
open val payments: PaymentsApi
|
||||
open val paymentsApi: PaymentsApi
|
||||
get() = AppDependencies.paymentsApi
|
||||
|
||||
open val profile: ProfileApi
|
||||
open val profileApi: ProfileApi
|
||||
get() = AppDependencies.profileApi
|
||||
|
||||
open val provisioning: ProvisioningApi
|
||||
open val provisioningApi: ProvisioningApi
|
||||
get() = AppDependencies.provisioningApi
|
||||
|
||||
open val rateLimitChallenge: RateLimitChallengeApi
|
||||
open val rateLimitChallengeApi: RateLimitChallengeApi
|
||||
get() = AppDependencies.rateLimitChallengeApi
|
||||
|
||||
open val remoteConfig: RemoteConfigApi
|
||||
open val remoteConfigApi: RemoteConfigApi
|
||||
get() = AppDependencies.remoteConfigApi
|
||||
|
||||
open val storageService: StorageServiceApi
|
||||
open val storageApi: StorageServiceApi
|
||||
get() = AppDependencies.storageServiceApi
|
||||
|
||||
open val svrB: SvrBApi
|
||||
open val svrBApi: SvrBApi
|
||||
get() = AppDependencies.svrBApi
|
||||
|
||||
open val username: UsernameApi
|
||||
open val usernameApi: UsernameApi
|
||||
get() = AppDependencies.usernameApi
|
||||
|
||||
open val archiveService: ArchiveService
|
||||
get() = AppDependencies.archiveService
|
||||
|
||||
open val donationsService: DonationsService
|
||||
get() = AppDependencies.donationsService
|
||||
|
||||
open val messageService: MessageService
|
||||
get() = AppDependencies.messageService
|
||||
|
||||
open val profileService: ProfileService
|
||||
get() = AppDependencies.profileService
|
||||
|
||||
open val storageService: StorageServiceService
|
||||
get() = AppDependencies.storageService
|
||||
|
||||
open val usernameService: UsernameService
|
||||
get() = AppDependencies.usernameService
|
||||
|
||||
companion object {
|
||||
|
||||
private var instance: SignalNetwork = SignalNetwork()
|
||||
@@ -108,34 +132,34 @@ open class SignalNetwork {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("account")
|
||||
val account: AccountApi
|
||||
get() = instance.account
|
||||
@get:JvmName("accountApi")
|
||||
val accountApi: AccountApi
|
||||
get() = instance.accountApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("accountV2")
|
||||
val accountV2: AccountApiV2
|
||||
get() = instance.accountV2
|
||||
@get:JvmName("accountApiV2")
|
||||
val accountApiV2: AccountApiV2
|
||||
get() = instance.accountApiV2
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("archive")
|
||||
val archive: ArchiveApi
|
||||
get() = instance.archive
|
||||
@get:JvmName("archiveApi")
|
||||
val archiveApi: ArchiveApi
|
||||
get() = instance.archiveApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("archiveV2")
|
||||
val archiveV2: ArchiveApiV2
|
||||
get() = instance.archiveV2
|
||||
@get:JvmName("archiveApiV2")
|
||||
val archiveApiV2: ArchiveApiV2
|
||||
get() = instance.archiveApiV2
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("attachments")
|
||||
val attachments: AttachmentApi
|
||||
get() = instance.attachments
|
||||
@get:JvmName("attachmentApi")
|
||||
val attachmentApi: AttachmentApi
|
||||
get() = instance.attachmentApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("calling")
|
||||
val calling: CallingApi
|
||||
get() = instance.calling
|
||||
@get:JvmName("callingApi")
|
||||
val callingApi: CallingApi
|
||||
get() = instance.callingApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("cdsApi")
|
||||
@@ -143,68 +167,98 @@ open class SignalNetwork {
|
||||
get() = instance.cdsApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("certificate")
|
||||
val certificate: CertificateApi
|
||||
get() = instance.certificate
|
||||
@get:JvmName("certificateApi")
|
||||
val certificateApi: CertificateApi
|
||||
get() = instance.certificateApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("keys")
|
||||
val keys: KeysApi
|
||||
get() = instance.keys
|
||||
@get:JvmName("keysApi")
|
||||
val keysApi: KeysApi
|
||||
get() = instance.keysApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("keyTransparency")
|
||||
val keyTransparency: KeyTransparencyApi
|
||||
get() = instance.keyTransparency
|
||||
@get:JvmName("keyTransparencyApi")
|
||||
val keyTransparencyApi: KeyTransparencyApi
|
||||
get() = instance.keyTransparencyApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("linkDevice")
|
||||
val linkDevice: LinkDeviceApi
|
||||
get() = instance.linkDevice
|
||||
@get:JvmName("linkDeviceApi")
|
||||
val linkDeviceApi: LinkDeviceApi
|
||||
get() = instance.linkDeviceApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("message")
|
||||
val message: MessageApi
|
||||
get() = instance.message
|
||||
@get:JvmName("messageApi")
|
||||
val messageApi: MessageApi
|
||||
get() = instance.messageApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("payments")
|
||||
val payments: PaymentsApi
|
||||
get() = instance.payments
|
||||
@get:JvmName("paymentsApi")
|
||||
val paymentsApi: PaymentsApi
|
||||
get() = instance.paymentsApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("profile")
|
||||
val profile: ProfileApi
|
||||
get() = instance.profile
|
||||
@get:JvmName("profileApi")
|
||||
val profileApi: ProfileApi
|
||||
get() = instance.profileApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("provisioning")
|
||||
val provisioning: ProvisioningApi
|
||||
get() = instance.provisioning
|
||||
@get:JvmName("provisioningApi")
|
||||
val provisioningApi: ProvisioningApi
|
||||
get() = instance.provisioningApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("rateLimitChallenge")
|
||||
val rateLimitChallenge: RateLimitChallengeApi
|
||||
get() = instance.rateLimitChallenge
|
||||
@get:JvmName("rateLimitChallengeApi")
|
||||
val rateLimitChallengeApi: RateLimitChallengeApi
|
||||
get() = instance.rateLimitChallengeApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("remoteConfig")
|
||||
val remoteConfig: RemoteConfigApi
|
||||
get() = instance.remoteConfig
|
||||
@get:JvmName("remoteConfigApi")
|
||||
val remoteConfigApi: RemoteConfigApi
|
||||
get() = instance.remoteConfigApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("storageApi")
|
||||
val storageApi: StorageServiceApi
|
||||
get() = instance.storageApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("svrBApi")
|
||||
val svrBApi: SvrBApi
|
||||
get() = instance.svrBApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("usernameApi")
|
||||
val usernameApi: UsernameApi
|
||||
get() = instance.usernameApi
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("archiveService")
|
||||
val archiveService: ArchiveService
|
||||
get() = instance.archiveService
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("donationsService")
|
||||
val donationsService: DonationsService
|
||||
get() = instance.donationsService
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("messageService")
|
||||
val messageService: MessageService
|
||||
get() = instance.messageService
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("profileService")
|
||||
val profileService: ProfileService
|
||||
get() = instance.profileService
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("storageService")
|
||||
val storageService: StorageServiceApi
|
||||
val storageService: StorageServiceService
|
||||
get() = instance.storageService
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("svrB")
|
||||
val svrB: SvrBApi
|
||||
get() = instance.svrB
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("username")
|
||||
val username: UsernameApi
|
||||
get() = instance.username
|
||||
@get:JvmName("usernameService")
|
||||
val usernameService: UsernameService
|
||||
get() = instance.usernameService
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class Payments {
|
||||
public synchronized @NonNull CurrencyExchange getCurrencyExchange(boolean refreshIfAble) throws IOException {
|
||||
if (currencyConversions == null || shouldRefresh(refreshIfAble, currencyConversions.getTimestamp())) {
|
||||
Log.i(TAG, "Currency conversion data is unavailable or a refresh was requested and available");
|
||||
CurrencyConversions newCurrencyConversions = NetworkResultUtil.toBasicLegacy(SignalNetwork.payments().getCurrencyConversions());
|
||||
CurrencyConversions newCurrencyConversions = NetworkResultUtil.toBasicLegacy(SignalNetwork.paymentsApi().getCurrencyConversions());
|
||||
if (currencyConversions == null || (newCurrencyConversions != null && newCurrencyConversions.getTimestamp() > currencyConversions.getTimestamp())) {
|
||||
currencyConversions = newCurrencyConversions;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ object SvrRepository {
|
||||
check(SignalStore.svr.hasPin() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to set a registration lock!" }
|
||||
|
||||
Log.i(TAG, "[enableRegistrationLockForUserWithPin] Enabling registration lock.", true)
|
||||
SignalNetwork.account.enableRegistrationLock(SignalStore.svr.masterKey).successOrThrow()
|
||||
SignalNetwork.accountApi.enableRegistrationLock(SignalStore.svr.masterKey).successOrThrow()
|
||||
SignalStore.svr.isRegistrationLockEnabled = true
|
||||
Log.i(TAG, "[enableRegistrationLockForUserWithPin] Registration lock successfully enabled.", true)
|
||||
}
|
||||
@@ -409,7 +409,7 @@ object SvrRepository {
|
||||
check(SignalStore.svr.hasPin() && !SignalStore.svr.hasOptedOut()) { "Must have a PIN to disable registration lock!" }
|
||||
|
||||
Log.i(TAG, "[disableRegistrationLockForUserWithPin] Disabling registration lock.", true)
|
||||
SignalNetwork.account.disableRegistrationLock().successOrThrow()
|
||||
SignalNetwork.accountApi.disableRegistrationLock().successOrThrow()
|
||||
SignalStore.svr.isRegistrationLockEnabled = false
|
||||
Log.i(TAG, "[disableRegistrationLockForUserWithPin] Registration lock successfully disabled.", true)
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ object UsernameRepository {
|
||||
Log.d(TAG, "[createOrResetUsernameLink] Creating username link...")
|
||||
|
||||
val usernameLink = username.generateLink()
|
||||
when (val result = SignalNetwork.account.createUsernameLink(usernameLink)) {
|
||||
when (val result = SignalNetwork.accountApi.createUsernameLink(usernameLink)) {
|
||||
is RequestResult.Success -> {
|
||||
SignalStore.account.usernameLink = result.result
|
||||
|
||||
@@ -239,7 +239,7 @@ object UsernameRepository {
|
||||
|
||||
return Single
|
||||
.fromCallable {
|
||||
val username = when (val result = SignalNetwork.username.getDecryptedUsernameFromLinkServerIdAndEntropy(components.serverId, components.entropy)) {
|
||||
val username = when (val result = SignalNetwork.usernameApi.getDecryptedUsernameFromLinkServerIdAndEntropy(components.serverId, components.entropy)) {
|
||||
is RequestResult.Success ->
|
||||
result.result ?: return@fromCallable UsernameLinkConversionResult.NotFound(null)
|
||||
is RequestResult.NonSuccess -> {
|
||||
@@ -259,7 +259,7 @@ object UsernameRepository {
|
||||
}
|
||||
}
|
||||
|
||||
when (val result = SignalNetwork.username.getAciByUsername(username)) {
|
||||
when (val result = SignalNetwork.usernameApi.getAciByUsername(username)) {
|
||||
is RequestResult.Success -> {
|
||||
result.result?.let {
|
||||
UsernameLinkConversionResult.Success(username, it)
|
||||
@@ -286,7 +286,7 @@ object UsernameRepository {
|
||||
return UsernameAciFetchResult.NotFound
|
||||
}
|
||||
|
||||
return when (val result = SignalNetwork.username.getAciByUsername(username)) {
|
||||
return when (val result = SignalNetwork.usernameApi.getAciByUsername(username)) {
|
||||
is RequestResult.Success -> {
|
||||
result.result?.let {
|
||||
UsernameAciFetchResult.Success(it)
|
||||
@@ -397,7 +397,7 @@ object UsernameRepository {
|
||||
}
|
||||
|
||||
private suspend fun reserveUsernameInternal(nickname: String, discriminator: String?): Result<UsernameState.Reserved, UsernameSetResult> {
|
||||
return when (val result = AppDependencies.usernameService.reserveUsername(nickname, discriminator)) {
|
||||
return when (val result = SignalNetwork.usernameService.reserveUsername(nickname, discriminator)) {
|
||||
is RequestResult.Success -> success(UsernameState.Reserved(result.result))
|
||||
is RequestResult.NonSuccess -> when (result.error) {
|
||||
is ReserveUsernameError.NicknameInvalid -> failure(UsernameSetResult.CANDIDATE_GENERATION_ERROR)
|
||||
@@ -424,7 +424,7 @@ object UsernameRepository {
|
||||
val oldUsernameLink = SignalStore.account.usernameLink ?: return UsernameSetResult.USERNAME_INVALID
|
||||
val newUsernameLink = updatedUsername.generateLink(oldUsernameLink.entropy)
|
||||
|
||||
return when (val result = SignalNetwork.account.updateUsernameLink(newUsernameLink)) {
|
||||
return when (val result = SignalNetwork.accountApi.updateUsernameLink(newUsernameLink)) {
|
||||
is RequestResult.Success -> {
|
||||
persistUsernameAndLink(updatedUsername.username, result.result)
|
||||
Log.i(TAG, "[updateUsernameDisplayForCurrentLink] Successfully updated username.")
|
||||
@@ -446,7 +446,7 @@ object UsernameRepository {
|
||||
return UsernameSetResult.NETWORK_ERROR
|
||||
}
|
||||
|
||||
return when (val result = AppDependencies.usernameService.confirmUsername(username)) {
|
||||
return when (val result = SignalNetwork.usernameService.confirmUsername(username)) {
|
||||
is RequestResult.Success -> {
|
||||
persistUsernameAndLink(result.result.username.username, result.result.link)
|
||||
Log.i(TAG, "[confirmUsernameAndCreateNewLink] Successfully confirmed username.")
|
||||
@@ -478,7 +478,7 @@ object UsernameRepository {
|
||||
return UsernameDeleteResult.NETWORK_ERROR
|
||||
}
|
||||
|
||||
return when (val result = SignalNetwork.account.deleteUsernameHash()) {
|
||||
return when (val result = SignalNetwork.accountApi.deleteUsernameHash()) {
|
||||
is RequestResult.Success -> {
|
||||
SignalDatabase.recipients.setUsername(Recipient.self().id, null)
|
||||
SignalStore.account.username = null
|
||||
@@ -512,7 +512,7 @@ object UsernameRepository {
|
||||
private fun reclaimUsernameIfNecessaryInternal(username: Username, usernameLinkComponents: UsernameLinkComponents): UsernameReclaimResult {
|
||||
val link = username.generateLink(usernameLinkComponents.entropy)
|
||||
|
||||
return when (val result = SignalNetwork.account.confirmUsername(username, link)) {
|
||||
return when (val result = SignalNetwork.accountApi.confirmUsername(username, link)) {
|
||||
is NetworkResult.Success -> {
|
||||
SignalStore.account.usernameLink = UsernameLinkComponents(usernameLinkComponents.entropy, result.result)
|
||||
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ object ProofRequiredExceptionHandler {
|
||||
Log.w(TAG, "[Proof Required] Options: ${proofRequired.options}")
|
||||
|
||||
if (ProofRequiredException.Option.PUSH_CHALLENGE in proofRequired.options) {
|
||||
when (val result = SignalNetwork.rateLimitChallenge.requestPushChallenge()) {
|
||||
when (val result = SignalNetwork.rateLimitChallengeApi.requestPushChallenge()) {
|
||||
is NetworkResult.Success -> {
|
||||
Log.i(TAG, "[Proof Required] Successfully requested a challenge. Waiting up to $PUSH_CHALLENGE_TIMEOUT ms.")
|
||||
val success = PushChallengeRequest(PUSH_CHALLENGE_TIMEOUT).blockUntilSuccess()
|
||||
|
||||
@@ -110,7 +110,7 @@ public class RecaptchaProofActivity extends PassphraseRequiredActivity {
|
||||
try {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.rateLimitChallenge().submitCaptchaChallenge(challenge, token));
|
||||
NetworkResultUtil.toBasicLegacy(SignalNetwork.rateLimitChallengeApi().submitCaptchaChallenge(challenge, token));
|
||||
RateLimitUtil.retryAllRateLimitedMessages(this);
|
||||
Log.i(TAG, "Successfully completed reCAPTCHA.");
|
||||
return new TokenResult(true, true);
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ object QuickRegistrationRepository {
|
||||
val publicKey = ECPublicKey(decode(publicKeyEncoded))
|
||||
|
||||
SignalNetwork
|
||||
.provisioning
|
||||
.provisioningApi
|
||||
.sendReRegisterDeviceProvisioningMessage(
|
||||
ephemeralId,
|
||||
publicKey,
|
||||
@@ -150,7 +150,7 @@ object QuickRegistrationRepository {
|
||||
Log.d(TAG, "Waiting for restore method with token: ***${restoreMethodToken.takeLast(4)}")
|
||||
while (retries-- > 0 && result !is NetworkResult.Success && coroutineContext.isActive) {
|
||||
Log.d(TAG, "Waiting, remaining tries: $retries")
|
||||
result = SignalNetwork.provisioning.waitForRestoreMethod(restoreMethodToken)
|
||||
result = SignalNetwork.provisioningApi.waitForRestoreMethod(restoreMethodToken)
|
||||
Log.d(TAG, "Result: $result")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -705,7 +705,7 @@ object RegistrationRepository {
|
||||
while (timeRemaining > 0 && coroutineContext.isActive) {
|
||||
Log.d(TAG, "[waitForLinkAndSyncBackupDetails] Willing to wait for $timeRemaining ms...")
|
||||
|
||||
when (val result = SignalNetwork.linkDevice.waitForPrimaryDevice(timeout = 60.seconds)) {
|
||||
when (val result = SignalNetwork.linkDeviceApi.waitForPrimaryDevice(timeout = 60.seconds)) {
|
||||
is NetworkResult.Success -> {
|
||||
// The primary has responded: either with an archive location, or an error telling us not to expect one.
|
||||
Log.i(TAG, "[waitForLinkAndSyncBackupDetails] Primary responded (hasArchive=${result.result.hasArchive}, error=${result.result.error})")
|
||||
|
||||
+2
-2
@@ -25,10 +25,10 @@ import org.thoughtcrime.securesms.backup.v2.RemoteRestoreResult
|
||||
import org.thoughtcrime.securesms.backup.v2.RestoreTimestampResult
|
||||
import org.thoughtcrime.securesms.backup.v2.RestoreV2Event
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.RestoreDecisionState
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.Completed
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.keyvalue.Skipped
|
||||
import org.thoughtcrime.securesms.net.SignalNetwork
|
||||
import org.thoughtcrime.securesms.registration.data.QuickRegistrationRepository
|
||||
import org.whispersystems.signalservice.api.provisioning.RestoreMethod
|
||||
import kotlin.time.Duration
|
||||
@@ -63,7 +63,7 @@ class RemoteRestoreViewModel(isOnlyRestoreOption: Boolean) : ViewModel() {
|
||||
|
||||
if (result is RestoreTimestampResult.VerificationFailure && SignalStore.account.restoredAccountEntropyPool) {
|
||||
Log.w(TAG, "Resetting backup id reservation due to zk verification failure with restored AEP")
|
||||
result = when (val triggerResult = AppDependencies.archiveService.triggerBackupIdReservation(includeMedia = false)) {
|
||||
result = when (val triggerResult = SignalNetwork.archiveService.triggerBackupIdReservation(includeMedia = false)) {
|
||||
is Either.Right -> {
|
||||
Log.i(TAG, "Reset successful, trying to restore timestamp")
|
||||
BackupRepository.restoreBackupFileTimestamp()
|
||||
|
||||
+9
-9
@@ -363,11 +363,11 @@ class AppRegistrationNetworkController(
|
||||
return@withContext RequestResult.NonSuccess(SetRegistrationLockError.NoPinSet)
|
||||
}
|
||||
|
||||
SignalNetwork.account.enableRegistrationLock(masterKey)
|
||||
SignalNetwork.accountApi.enableRegistrationLock(masterKey)
|
||||
}
|
||||
|
||||
override suspend fun disableRegistrationLock(): RequestResult<Unit, SetRegistrationLockError> = withContext(Dispatchers.IO) {
|
||||
SignalNetwork.account.disableRegistrationLock()
|
||||
SignalNetwork.accountApi.disableRegistrationLock()
|
||||
}
|
||||
|
||||
override suspend fun getSvrCredentials(): RequestResult<SvrCredentials, GetSvrCredentialsError> = withContext(Dispatchers.IO) {
|
||||
@@ -392,7 +392,7 @@ class AppRegistrationNetworkController(
|
||||
override suspend fun setAccountAttributes(
|
||||
attributes: AccountAttributes
|
||||
): RequestResult<Unit, SetAccountAttributesError> = withContext(Dispatchers.IO) {
|
||||
when (val result = SignalNetwork.account.setAccountAttributes(attributes.toServiceAccountAttributes())) {
|
||||
when (val result = SignalNetwork.accountApi.setAccountAttributes(attributes.toServiceAccountAttributes())) {
|
||||
is NetworkResult.Success -> RequestResult.Success(Unit)
|
||||
is NetworkResult.StatusCodeError -> {
|
||||
when (result.code) {
|
||||
@@ -409,7 +409,7 @@ class AppRegistrationNetworkController(
|
||||
override suspend fun getRemoteBackupInfo(aep: AccountEntropyPool): RequestResult<NetworkController.GetBackupInfoResponse, NetworkController.GetBackupInfoError> = withContext(Dispatchers.IO) {
|
||||
val aci = SignalStore.account.aci ?: return@withContext RequestResult.ApplicationError(IllegalStateException("ACI not available"))
|
||||
|
||||
AppDependencies.archiveService
|
||||
SignalNetwork.archiveService
|
||||
.getMessageBackupInfoForKey(aci, aep.deriveMessageBackupKey())
|
||||
.fold(
|
||||
ifRight = { info ->
|
||||
@@ -431,7 +431,7 @@ class AppRegistrationNetworkController(
|
||||
val aci = SignalStore.account.aci ?: return@withContext RequestResult.ApplicationError(IllegalStateException("ACI not available"))
|
||||
|
||||
// Uses API directly because ArchiveService uses stored key
|
||||
when (val result = SignalNetwork.archiveV2.triggerBackupIdReservation(messageBackupKey = aep.deriveMessageBackupKey(), mediaRootBackupKey = null, aci = aci)) {
|
||||
when (val result = SignalNetwork.archiveApiV2.triggerBackupIdReservation(messageBackupKey = aep.deriveMessageBackupKey(), mediaRootBackupKey = null, aci = aci)) {
|
||||
is RequestResult.Success -> {
|
||||
// Anything cached was issued against the backup-id we just replaced, so it can never verify.
|
||||
SignalStore.backup.messageCredentials.clearAll()
|
||||
@@ -492,11 +492,11 @@ class AppRegistrationNetworkController(
|
||||
}
|
||||
|
||||
override suspend fun reserveUsername(nickname: String, discriminator: String?): RequestResult<Username, ReserveUsernameError> {
|
||||
return AppDependencies.usernameService.reserveUsername(nickname, discriminator)
|
||||
return SignalNetwork.usernameService.reserveUsername(nickname, discriminator)
|
||||
}
|
||||
|
||||
override suspend fun confirmUsername(username: Username): RequestResult<ConfirmedUsername, ConfirmUsernameError> {
|
||||
return AppDependencies.usernameService.confirmUsername(username)
|
||||
return SignalNetwork.usernameService.confirmUsername(username)
|
||||
}
|
||||
|
||||
override suspend fun restoreAccountRecord(
|
||||
@@ -523,7 +523,7 @@ class AppRegistrationNetworkController(
|
||||
): RequestResult<Long, NetworkController.GetBackupInfoError> = withContext(Dispatchers.IO) {
|
||||
val aci = SignalStore.account.aci ?: return@withContext RequestResult.ApplicationError(IllegalStateException("ACI not available"))
|
||||
|
||||
val location = when (val result = AppDependencies.archiveService.getMessageBackupFileLocationForKey(aci, aep.deriveMessageBackupKey())) {
|
||||
val location = when (val result = SignalNetwork.archiveService.getMessageBackupFileLocationForKey(aci, aep.deriveMessageBackupKey())) {
|
||||
is Either.Right -> result.value
|
||||
is Either.Left -> return@withContext result.value.toGetBackupInfoError()
|
||||
}
|
||||
@@ -853,7 +853,7 @@ class AppRegistrationNetworkController(
|
||||
while (timeRemaining > 0 && coroutineContext.isActive) {
|
||||
Log.d(TAG, "[awaitTransferArchiveFromPrimary] Willing to wait for $timeRemaining ms...")
|
||||
|
||||
when (val result = SignalNetwork.linkDevice.waitForPrimaryDevice(timeout = 60.seconds)) {
|
||||
when (val result = SignalNetwork.linkDeviceApi.waitForPrimaryDevice(timeout = 60.seconds)) {
|
||||
is NetworkResult.Success -> {
|
||||
Log.i(TAG, "[awaitTransferArchiveFromPrimary] Primary responded (hasArchive=${result.result.hasArchive}, error=${result.result.error})")
|
||||
return result.result
|
||||
|
||||
@@ -995,7 +995,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
headerPairs = Collections.emptyList();
|
||||
}
|
||||
|
||||
NetworkResult<CallingResponse> result = SignalNetwork.calling()
|
||||
NetworkResult<CallingResponse> result = SignalNetwork.callingApi()
|
||||
.makeCallingRequest(requestId, url, httpMethod.name(), headerPairs, body);
|
||||
|
||||
CallingResponse response = ((NetworkResult.Success<CallingResponse>) result).getResult();
|
||||
@@ -1172,7 +1172,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
|
||||
return;
|
||||
}
|
||||
|
||||
List<TurnServerInfo> turnServerInfos = NetworkResultUtil.toBasicLegacy(SignalNetwork.calling().getTurnServerInfo());
|
||||
List<TurnServerInfo> turnServerInfos = NetworkResultUtil.toBasicLegacy(SignalNetwork.callingApi().getTurnServerInfo());
|
||||
|
||||
// Find *any* provided ttl values as long as they are valid.
|
||||
long minTtl = turnServerInfos.stream()
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class SignalCallLinkManager(
|
||||
|
||||
Log.d(TAG, "Requesting call link credential response.")
|
||||
|
||||
when (val result: NetworkResult<CreateCallLinkCredentialResponse> = SignalNetwork.calling.createCallLinkCredential(request)) {
|
||||
when (val result: NetworkResult<CreateCallLinkCredentialResponse> = SignalNetwork.callingApi.createCallLinkCredential(request)) {
|
||||
is NetworkResult.Success -> {
|
||||
Log.d(TAG, "Requesting call link credential.")
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ public final class ProfileUtil {
|
||||
}
|
||||
|
||||
ProfileKey profileKey = ProfileKeyUtil.getSelfProfileKey();
|
||||
NetworkResult<String> result = SignalNetwork.profile().setVersionedProfile(SignalStore.account().requireAci(),
|
||||
NetworkResult<String> result = SignalNetwork.profileApi().setVersionedProfile(SignalStore.account().requireAci(),
|
||||
profileKey,
|
||||
profileName.serialize(),
|
||||
about,
|
||||
|
||||
@@ -124,7 +124,7 @@ object RemoteConfig {
|
||||
@WorkerThread
|
||||
@Throws(IOException::class)
|
||||
fun refreshSync() {
|
||||
val result = NetworkResultUtil.toBasicLegacy(SignalNetwork.remoteConfig.getRemoteConfig())
|
||||
val result = NetworkResultUtil.toBasicLegacy(SignalNetwork.remoteConfigApi.getRemoteConfig())
|
||||
update(result.config)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ object VerifySafetyNumberRepository {
|
||||
|
||||
val aciIdentityKey = identityRecord.get().identityKey
|
||||
|
||||
val result = SignalNetwork.keyTransparency.check(
|
||||
val result = SignalNetwork.keyTransparencyApi.check(
|
||||
checkMode = CheckMode.Contact,
|
||||
aci = recipient.requireAci().libSignalAci,
|
||||
aciIdentityKey = aciIdentityKey,
|
||||
|
||||
@@ -71,12 +71,12 @@ class BackupPlugin : Plugin {
|
||||
return "Failed to read forward secrecy metadata!"
|
||||
}
|
||||
|
||||
val svrBAuth = when (val result = runBlocking { AppDependencies.archiveService.getSvrBAuth() }) {
|
||||
val svrBAuth = when (val result = runBlocking { SignalNetwork.archiveService.getSvrBAuth() }) {
|
||||
is Either.Right -> result.value
|
||||
is Either.Left -> return "Failed to read forward secrecy metadata!"
|
||||
}
|
||||
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrB.restore(svrBAuth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
val forwardSecrecyToken = when (val result = SignalNetwork.svrBApi.restore(svrBAuth, SignalStore.backup.messageBackupKey, forwardSecrecyMetadata)) {
|
||||
is SvrBApi.RestoreResult.Success -> result.data.forwardSecrecyToken
|
||||
else -> return "Failed to read forward secrecy metadata! $result"
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class StorageServicePlugin : Plugin {
|
||||
val columns = listOf("Type", "Id", "Data")
|
||||
val rows = mutableListOf<List<String>>()
|
||||
|
||||
val repository = StorageServiceService(SignalNetwork.storageService)
|
||||
val repository = SignalNetwork.storageService
|
||||
val storageServiceKey = SignalStore.storageService.storageKey
|
||||
|
||||
val manifest = when (val result = repository.getStorageManifest(storageServiceKey)) {
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ class ExportAccountDataTest {
|
||||
fun `Export json without text field`() {
|
||||
val scheduler = TestScheduler()
|
||||
|
||||
every { SignalNetwork.account.accountDataReport() } returns NetworkResult.Success(mockJson)
|
||||
every { SignalNetwork.accountApi.accountDataReport() } returns NetworkResult.Success(mockJson)
|
||||
|
||||
val viewModel = ExportAccountDataViewModel(ExportAccountDataRepository())
|
||||
|
||||
|
||||
+5
@@ -27,6 +27,7 @@ import org.signal.network.api.SvrBApi
|
||||
import org.signal.network.api.UsernameApi
|
||||
import org.signal.network.config.SignalServiceConfiguration
|
||||
import org.signal.network.rest.SignalRestClient
|
||||
import org.signal.network.service.StorageServiceService
|
||||
import org.signal.network.service.UsernameService
|
||||
import org.signal.video.exo.ExoPlayerPool
|
||||
import org.thoughtcrime.securesms.components.TypingStatusRepository
|
||||
@@ -118,6 +119,10 @@ class MockApplicationDependencyProvider : AppDependencies.Provider {
|
||||
return mockk(relaxed = true)
|
||||
}
|
||||
|
||||
override fun provideStorageService(storageServiceApi: StorageServiceApi): StorageServiceService {
|
||||
return mockk(relaxed = true)
|
||||
}
|
||||
|
||||
override fun provideMessageService(
|
||||
protocolStore: SignalServiceDataStore,
|
||||
messageApiV2: org.signal.network.api.MessageApiV2,
|
||||
|
||||
@@ -40,11 +40,11 @@ class LinkDeviceRepositoryTest {
|
||||
fun setUp() {
|
||||
Log.initialize(SystemOutLogger())
|
||||
|
||||
val signalApi = mockk<SignalNetwork>()
|
||||
every { signalApi.attachments } returns attachments
|
||||
every { signalApi.archive } returns archive
|
||||
val signalNetwork = mockk<SignalNetwork>()
|
||||
every { signalNetwork.attachmentApi } returns attachments
|
||||
every { signalNetwork.archiveApi } returns archive
|
||||
|
||||
SignalNetwork.init(signalApi)
|
||||
SignalNetwork.init(signalNetwork)
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.Currency
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
/**
|
||||
* An in-memory stand-in for the storage service, installed over [SignalNetwork.storageService].
|
||||
* An in-memory stand-in for the storage service, installed over [SignalNetwork.storageApi].
|
||||
*
|
||||
* Records are stored encrypted with [storageKey], exactly as they would be remotely, so tests get a real
|
||||
* encrypt/decrypt round-trip. Seed remote state with [setRemoteState], and inspect the results of a sync
|
||||
@@ -91,10 +91,11 @@ class FakeStorageServiceRule(val storageKey: StorageKey = StorageKey(Util.getSec
|
||||
every { api.readStorageItems(any(), any()) } answers { readStorageItems(secondArg()) }
|
||||
every { api.writeStorageItems(any(), any()) } answers { writeStorageItems(secondArg()) }
|
||||
|
||||
val signalApi = mockk<SignalNetwork>()
|
||||
every { signalApi.storageService } returns api
|
||||
val signalNetwork = mockk<SignalNetwork>()
|
||||
every { signalNetwork.storageApi } returns api
|
||||
every { signalNetwork.storageService } returns service
|
||||
|
||||
SignalNetwork.init(signalApi)
|
||||
SignalNetwork.init(signalNetwork)
|
||||
}
|
||||
|
||||
override fun after() {
|
||||
|
||||
Reference in New Issue
Block a user