mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Make sure note to self is included in backupsV2.
This commit is contained in:
committed by
Nicholas Tinsley
parent
0465fdea62
commit
227a279131
@@ -72,7 +72,6 @@ class MessageBackupsFlowViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
private fun validateTypeAndUpdateState(): MessageBackupsScreen {
|
||||
SignalStore.backup().canReadWriteToArchiveCdn = state.value.selectedMessageBackupTier == MessageBackupTier.PAID
|
||||
SignalStore.backup().areBackupsEnabled = true
|
||||
return MessageBackupsScreen.COMPLETED
|
||||
// return MessageBackupsScreen.CHECKOUT_SHEET TODO [message-backups] Switch back to payment flow
|
||||
|
||||
@@ -170,7 +170,7 @@ class InternalBackupPlaygroundFragment : ComposeFragment() {
|
||||
},
|
||||
mediaContent = { snackbarHostState ->
|
||||
MediaList(
|
||||
enabled = SignalStore.backup().canReadWriteToArchiveCdn,
|
||||
enabled = SignalStore.backup().backsUpMedia,
|
||||
state = mediaState,
|
||||
snackbarHostState = snackbarHostState,
|
||||
archiveAttachmentMedia = { viewModel.archiveAttachmentMedia(it) },
|
||||
@@ -215,7 +215,7 @@ fun Tabs(
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
if (tabIndex == 1 && SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (tabIndex == 1 && SignalStore.backup().backsUpMedia) {
|
||||
TextButton(onClick = onDeleteAllArchivedMedia) {
|
||||
Text(text = "Delete All")
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class ArchiveAttachmentJob private constructor(private val attachmentId: Attachm
|
||||
const val KEY = "ArchiveAttachmentJob"
|
||||
|
||||
fun enqueueIfPossible(attachmentId: AttachmentId) {
|
||||
if (!SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (!SignalStore.backup().backsUpMedia) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class ArchiveAttachmentJob private constructor(private val attachmentId: Attachm
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun onRun() {
|
||||
if (!SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (!SignalStore.backup().backsUpMedia) {
|
||||
Log.w(TAG, "Do not have permission to read/write to archive cdn")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class ArchiveThumbnailUploadJob private constructor(
|
||||
private val TAG = Log.tag(ArchiveThumbnailUploadJob::class.java)
|
||||
|
||||
fun enqueueIfNecessary(attachmentId: AttachmentId) {
|
||||
if (SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (SignalStore.backup().backsUpMedia) {
|
||||
ApplicationDependencies.getJobManager().add(ArchiveThumbnailUploadJob(attachmentId))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ class AttachmentDownloadJob private constructor(
|
||||
|
||||
if ((attachment.cdn == Cdn.CDN_2 || attachment.cdn == Cdn.CDN_3) &&
|
||||
attachment.archiveMediaId == null &&
|
||||
SignalStore.backup().canReadWriteToArchiveCdn
|
||||
SignalStore.backup().backsUpMedia
|
||||
) {
|
||||
ApplicationDependencies.getJobManager().add(ArchiveAttachmentJob(attachmentId))
|
||||
}
|
||||
@@ -212,7 +212,7 @@ class AttachmentDownloadJob private constructor(
|
||||
throw MmsException("Attachment too large, failing download")
|
||||
}
|
||||
|
||||
useArchiveCdn = if (SignalStore.backup().canReadWriteToArchiveCdn && (forceArchiveDownload || attachment.remoteLocation == null)) {
|
||||
useArchiveCdn = if (SignalStore.backup().backsUpMedia && (forceArchiveDownload || attachment.remoteLocation == null)) {
|
||||
if (attachment.archiveMediaName.isNullOrEmpty()) {
|
||||
throw InvalidPartException("Invalid attachment configuration")
|
||||
}
|
||||
@@ -272,7 +272,7 @@ class AttachmentDownloadJob private constructor(
|
||||
Log.w(TAG, "Experienced exception while trying to download an attachment.", e)
|
||||
markFailed(messageId, attachmentId)
|
||||
} catch (e: NonSuccessfulResponseCodeException) {
|
||||
if (SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (SignalStore.backup().backsUpMedia) {
|
||||
if (e.code == 404 && !useArchiveCdn && attachment.archiveMediaName?.isNotEmpty() == true) {
|
||||
Log.i(TAG, "Retrying download from archive CDN")
|
||||
forceArchiveDownload = true
|
||||
|
||||
@@ -58,7 +58,7 @@ class BackupMessagesJob private constructor(parameters: Parameters) : BaseJob(pa
|
||||
override fun onFailure() = Unit
|
||||
|
||||
private fun archiveAttachments(): Boolean {
|
||||
if (!SignalStore.backup().canReadWriteToArchiveCdn) return false
|
||||
if (!SignalStore.backup().backsUpMedia) return false
|
||||
|
||||
val batchSize = 100
|
||||
var needToBackfill = 0
|
||||
|
||||
@@ -202,7 +202,7 @@ class RestoreAttachmentJob private constructor(
|
||||
throw MmsException("Attachment too large, failing download")
|
||||
}
|
||||
|
||||
useArchiveCdn = if (SignalStore.backup().canReadWriteToArchiveCdn && (forceArchiveDownload || attachment.remoteLocation == null)) {
|
||||
useArchiveCdn = if (SignalStore.backup().backsUpMedia && (forceArchiveDownload || attachment.remoteLocation == null)) {
|
||||
if (attachment.archiveMediaName.isNullOrEmpty()) {
|
||||
throw InvalidPartException("Invalid attachment configuration")
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class RestoreAttachmentJob private constructor(
|
||||
Log.w(TAG, "Experienced exception while trying to download an attachment.", e)
|
||||
markFailed(messageId, attachmentId)
|
||||
} catch (e: NonSuccessfulResponseCodeException) {
|
||||
if (SignalStore.backup().canReadWriteToArchiveCdn) {
|
||||
if (SignalStore.backup().backsUpMedia) {
|
||||
if (e.code == 404 && !useArchiveCdn && attachment.archiveMediaName?.isNotEmpty() == true) {
|
||||
Log.i(TAG, "Retrying download from archive CDN")
|
||||
forceArchiveDownload = true
|
||||
|
||||
@@ -53,7 +53,6 @@ internal class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
override fun onFirstEverAppLaunch() = Unit
|
||||
override fun getKeysToIncludeInBackup(): List<String> = emptyList()
|
||||
|
||||
var canReadWriteToArchiveCdn: Boolean by booleanValue(KEY_CDN_CAN_READ_WRITE, false)
|
||||
var restoreState: RestoreState by enumValue(KEY_RESTORE_STATE, RestoreState.NONE, RestoreState.serializer)
|
||||
var optimizeStorage: Boolean by booleanValue(KEY_OPTIMIZE_STORAGE, false)
|
||||
var backupWithCellular: Boolean by booleanValue(KEY_BACKUP_OVER_CELLULAR, false)
|
||||
@@ -64,6 +63,11 @@ internal class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
|
||||
val totalBackupSize: Long get() = lastBackupProtoSize + usedBackupMediaSpace
|
||||
|
||||
/** True if the user backs up media, otherwise false. */
|
||||
val backsUpMedia: Boolean
|
||||
@JvmName("backsUpMedia")
|
||||
get() = backupTier == MessageBackupTier.PAID
|
||||
|
||||
var areBackupsEnabled: Boolean
|
||||
get() {
|
||||
return getBoolean(KEY_BACKUPS_ENABLED, false)
|
||||
@@ -78,7 +82,7 @@ internal class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
}
|
||||
|
||||
val backupTier: MessageBackupTier? = if (areBackupsEnabled) {
|
||||
if (canReadWriteToArchiveCdn) {
|
||||
if (backsUpMedia) {
|
||||
MessageBackupTier.PAID
|
||||
} else {
|
||||
MessageBackupTier.FREE
|
||||
|
||||
@@ -394,7 +394,7 @@ public class MessageSender {
|
||||
Recipient recipient = messages.get(i).getThreadRecipient();
|
||||
|
||||
if (isLocalSelfSend(context, recipient, SendType.SIGNAL)) {
|
||||
sendLocalMediaSelf(context, messageId);
|
||||
sendLocalMediaSelf(messageId);
|
||||
} else if (recipient.isPushGroup()) {
|
||||
jobManager.add(new PushGroupSendJob(messageId, recipient.getId(), Collections.emptySet(), true, false), messageDependsOnIds, recipient.getId().toQueueKey());
|
||||
} else if (recipient.isDistributionList()) {
|
||||
@@ -526,8 +526,8 @@ public class MessageSender {
|
||||
@NonNull Collection<String> uploadJobIds,
|
||||
boolean isScheduledSend)
|
||||
{
|
||||
if (isLocalSelfSend(context, recipient, sendType) && !isScheduledSend) {
|
||||
sendLocalMediaSelf(context, messageId);
|
||||
if (isLocalSelfSend(context, recipient, sendType) && !isScheduledSend && !SignalStore.backup().backsUpMedia()) {
|
||||
sendLocalMediaSelf(messageId);
|
||||
} else if (recipient.isPushGroup()) {
|
||||
sendGroupPush(context, recipient, messageId, Collections.emptySet(), uploadJobIds);
|
||||
} else if (recipient.isDistributionList()) {
|
||||
@@ -608,13 +608,13 @@ public class MessageSender {
|
||||
!TextSecurePreferences.isMultiDevice(context);
|
||||
}
|
||||
|
||||
private static void sendLocalMediaSelf(Context context, long messageId) {
|
||||
private static void sendLocalMediaSelf(long messageId) {
|
||||
try {
|
||||
ExpiringMessageManager expirationManager = ApplicationDependencies.getExpiringMessageManager();
|
||||
MessageTable mmsDatabase = SignalDatabase.messages();
|
||||
OutgoingMessage message = mmsDatabase.getOutgoingMessage(messageId);
|
||||
SyncMessageId syncId = new SyncMessageId(Recipient.self().getId(), message.getSentTimeMillis());
|
||||
List<Attachment> attachments = new LinkedList<>();
|
||||
List<Attachment> attachments = new LinkedList<>();
|
||||
|
||||
|
||||
attachments.addAll(message.getAttachments());
|
||||
|
||||
Reference in New Issue
Block a user