mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Inline the deleteSync capability.
This commit is contained in:
@@ -31,7 +31,6 @@ import org.signal.core.ui.SignalPreview
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.compose.ComposeBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
/**
|
||||
* Show educational info about delete syncing to linked devices. This dialog uses a subject to convey when
|
||||
@@ -45,8 +44,7 @@ class DeleteSyncEducationDialog : ComposeBottomSheetDialogFragment() {
|
||||
@JvmStatic
|
||||
fun shouldShow(): Boolean {
|
||||
return SignalStore.account.hasLinkedDevices &&
|
||||
!SignalStore.uiHints.hasSeenDeleteSyncEducationSheet &&
|
||||
Recipient.self().deleteSyncCapability.isSupported
|
||||
!SignalStore.uiHints.hasSeenDeleteSyncEducationSheet
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -70,7 +70,6 @@ import org.thoughtcrime.securesms.keyvalue.KeepMessagesDuration
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity
|
||||
import org.thoughtcrime.securesms.preferences.widgets.StorageGraphView
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.util.viewModel
|
||||
@@ -158,7 +157,7 @@ class ManageStorageSettingsFragment : ComposeFragment() {
|
||||
dialog("confirm-delete-chat-history") {
|
||||
Dialogs.SimpleAlertDialog(
|
||||
title = stringResource(id = R.string.preferences_storage__delete_message_history),
|
||||
body = if (SignalStore.account.hasLinkedDevices && Recipient.self().deleteSyncCapability.isSupported) {
|
||||
body = if (SignalStore.account.hasLinkedDevices) {
|
||||
stringResource(id = R.string.preferences_storage__this_will_delete_all_message_history_and_media_from_your_device_linked_device)
|
||||
} else {
|
||||
stringResource(id = R.string.preferences_storage__this_will_delete_all_message_history_and_media_from_your_device)
|
||||
@@ -174,7 +173,7 @@ class ManageStorageSettingsFragment : ComposeFragment() {
|
||||
dialog("double-confirm-delete-chat-history", dialogProperties = DialogProperties(dismissOnBackPress = true, dismissOnClickOutside = true)) {
|
||||
Dialogs.SimpleAlertDialog(
|
||||
title = stringResource(id = R.string.preferences_storage__are_you_sure_you_want_to_delete_all_message_history),
|
||||
body = if (SignalStore.account.hasLinkedDevices && Recipient.self().deleteSyncCapability.isSupported) {
|
||||
body = if (SignalStore.account.hasLinkedDevices) {
|
||||
stringResource(id = R.string.preferences_storage__all_message_history_will_be_permanently_removed_this_action_cannot_be_undone_linked_device)
|
||||
} else {
|
||||
stringResource(id = R.string.preferences_storage__all_message_history_will_be_permanently_removed_this_action_cannot_be_undone)
|
||||
|
||||
@@ -341,8 +341,6 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
|
||||
return if (capabilities != null) {
|
||||
TextUtils.concat(
|
||||
colorize("DeleteSync", capabilities.deleteSync),
|
||||
", ",
|
||||
colorize("SSREv2", capabilities.storageServiceEncryptionV2)
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -1241,7 +1241,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
||||
alert.setTitle(context.getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations,
|
||||
conversationsCount, conversationsCount));
|
||||
|
||||
if (SignalStore.account().hasLinkedDevices() && Recipient.self().getDeleteSyncCapability().isSupported()) {
|
||||
if (SignalStore.account().hasLinkedDevices()) {
|
||||
alert.setMessage(context.getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations_linked_device,
|
||||
conversationsCount, conversationsCount));
|
||||
} else {
|
||||
|
||||
@@ -418,7 +418,6 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
@JvmStatic
|
||||
fun maskCapabilitiesToLong(capabilities: SignalServiceProfile.Capabilities): Long {
|
||||
var value: Long = 0
|
||||
value = Bitmask.update(value, Capabilities.DELETE_SYNC, Capabilities.BIT_LENGTH, Recipient.Capability.fromBoolean(capabilities.isDeleteSync).serialize().toLong())
|
||||
value = Bitmask.update(value, Capabilities.STORAGE_SERVICE_ENCRYPTION_V2, Capabilities.BIT_LENGTH, Recipient.Capability.fromBoolean(capabilities.isStorageServiceEncryptionV2).serialize().toLong())
|
||||
return value
|
||||
}
|
||||
@@ -4711,8 +4710,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
// const val GIFT_BADGES = 6
|
||||
// const val PNP = 7
|
||||
// const val PAYMENT_ACTIVATION = 8
|
||||
const val DELETE_SYNC = 9
|
||||
|
||||
// const val DELETE_SYNC = 9
|
||||
// const val VERSIONED_EXPIRATION_TIMER = 10
|
||||
const val STORAGE_SERVICE_ENCRYPTION_V2 = 11
|
||||
|
||||
|
||||
@@ -176,7 +176,6 @@ object RecipientTableCursorUtil {
|
||||
val capabilities = cursor.requireLong(RecipientTable.CAPABILITIES)
|
||||
return RecipientRecord.Capabilities(
|
||||
rawBits = capabilities,
|
||||
deleteSync = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.DELETE_SYNC, Capabilities.BIT_LENGTH).toInt()),
|
||||
storageServiceEncryptionV2 = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.STORAGE_SERVICE_ENCRYPTION_V2, Capabilities.BIT_LENGTH).toInt())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
return
|
||||
}
|
||||
|
||||
val syncThreadTrimDeletes = SignalStore.settings.shouldSyncThreadTrimDeletes() && Recipient.self().deleteSyncCapability.isSupported
|
||||
val syncThreadTrimDeletes = SignalStore.settings.shouldSyncThreadTrimDeletes()
|
||||
val threadTrimsToSync = mutableListOf<ThreadDeleteSyncInfo>()
|
||||
|
||||
readableDatabase
|
||||
@@ -1267,7 +1267,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
|
||||
val queries: List<SqlUtil.Query> = SqlUtil.buildCollectionQuery(ID, selectedConversations)
|
||||
writableDatabase.withinTransaction { db ->
|
||||
if (syncThreadDeletes && Recipient.self().deleteSyncCapability.isSupported) {
|
||||
if (syncThreadDeletes) {
|
||||
for (threadId in selectedConversations) {
|
||||
val mostRecentMessages = messages.getMostRecentAddressableMessages(threadId, excludeExpiring = false)
|
||||
val mostRecentNonExpiring = if (mostRecentMessages.size == MessageTable.ADDRESSABLE_MESSAGE_LIMIT && mostRecentMessages.any { it.expiresIn > 0 }) {
|
||||
|
||||
@@ -120,14 +120,12 @@ data class RecipientRecord(
|
||||
|
||||
data class Capabilities(
|
||||
val rawBits: Long,
|
||||
val deleteSync: Recipient.Capability,
|
||||
val storageServiceEncryptionV2: Recipient.Capability
|
||||
) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val UNKNOWN = Capabilities(
|
||||
rawBits = 0,
|
||||
deleteSync = Recipient.Capability.UNKNOWN,
|
||||
storageServiceEncryptionV2 = Recipient.Capability.UNKNOWN
|
||||
)
|
||||
}
|
||||
|
||||
@@ -61,11 +61,6 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (!Recipient.self().deleteSyncCapability.isSupported) {
|
||||
Log.i(TAG, "Delete sync support not enabled.")
|
||||
return
|
||||
}
|
||||
|
||||
messageRecords.chunked(CHUNK_SIZE).forEach { chunk ->
|
||||
val deletes = createMessageDeletes(chunk)
|
||||
if (deletes.isNotEmpty()) {
|
||||
@@ -83,11 +78,6 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (!Recipient.self().deleteSyncCapability.isSupported) {
|
||||
Log.i(TAG, "Delete sync support not enabled.")
|
||||
return
|
||||
}
|
||||
|
||||
val delete = createAttachmentDelete(message, attachment)
|
||||
if (delete != null) {
|
||||
AppDependencies.jobManager.add(MultiDeviceDeleteSyncJob(attachments = listOf(delete)))
|
||||
@@ -102,11 +92,6 @@ class MultiDeviceDeleteSyncJob private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
if (!Recipient.self().deleteSyncCapability.isSupported) {
|
||||
Log.i(TAG, "Delete sync support not enabled.")
|
||||
return
|
||||
}
|
||||
|
||||
threads.chunked(THREAD_CHUNK_SIZE).forEach { chunk ->
|
||||
val threadDeletes = createThreadDeletes(chunk, isFullDelete)
|
||||
if (threadDeletes.isNotEmpty()) {
|
||||
|
||||
@@ -220,11 +220,6 @@ public class RefreshOwnProfileJob extends BaseJob {
|
||||
|
||||
SignalDatabase.recipients().setCapabilities(Recipient.self().getId(), capabilities);
|
||||
|
||||
if (!selfSnapshot.getDeleteSyncCapability().isSupported() && capabilities.isDeleteSync()) {
|
||||
Log.d(TAG, "Transitioned to delete sync capable, notify linked devices in case we were the last one");
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
}
|
||||
|
||||
if (selfSnapshot.getStorageServiceEncryptionV2Capability() == Recipient.Capability.NOT_SUPPORTED && capabilities.isStorageServiceEncryptionV2()) {
|
||||
Log.i(TAG, "Transitioned to storageServiceEncryptionV2 capable. Notifying other devices and pushing to storage service with a recordIkm.");
|
||||
AppDependencies.getJobManager().add(new MultiDeviceProfileContentUpdateJob());
|
||||
|
||||
@@ -78,7 +78,7 @@ public class TrimThreadJob extends BaseJob {
|
||||
long trimBeforeDate = keepMessagesDuration != KeepMessagesDuration.FOREVER ? System.currentTimeMillis() - keepMessagesDuration.getDuration()
|
||||
: ThreadTable.NO_TRIM_BEFORE_DATE_SET;
|
||||
|
||||
SignalDatabase.threads().trimThread(threadId, SignalStore.settings().shouldSyncThreadTrimDeletes() && Recipient.self().getDeleteSyncCapability().isSupported(), trimLength, trimBeforeDate, false);
|
||||
SignalDatabase.threads().trimThread(threadId, SignalStore.settings().shouldSyncThreadTrimDeletes(), trimLength, trimBeforeDate, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,6 @@ public final class LogSectionCapabilities implements LogSection {
|
||||
.append("-- Global").append("\n");
|
||||
|
||||
if (globalCapabilities != null) {
|
||||
builder.append("DeleteSync: ").append(globalCapabilities.getDeleteSync()).append("\n");
|
||||
builder.append("StorageServiceEncryptionV2: ").append(globalCapabilities.getStorageServiceEncryptionV2()).append("\n");
|
||||
builder.append("\n");
|
||||
} else {
|
||||
|
||||
@@ -86,7 +86,7 @@ final class MediaActions {
|
||||
}
|
||||
}
|
||||
|
||||
if (Recipient.self().getDeleteSyncCapability().isSupported() && Util.hasItems(deletedMessageRecords)) {
|
||||
if (Util.hasItems(deletedMessageRecords)) {
|
||||
MultiDeviceDeleteSyncJob.enqueueMessageDeletes(deletedMessageRecords);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceDeleteSyncJob
|
||||
import org.thoughtcrime.securesms.longmessage.resolveBody
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.util.AttachmentUtil
|
||||
@@ -98,7 +97,7 @@ class MediaPreviewRepository {
|
||||
fun localDelete(attachment: DatabaseAttachment): Completable {
|
||||
return Completable.fromRunnable {
|
||||
val deletedMessageRecord = AttachmentUtil.deleteAttachment(attachment)
|
||||
if (deletedMessageRecord != null && Recipient.self().deleteSyncCapability.isSupported) {
|
||||
if (deletedMessageRecord != null) {
|
||||
MultiDeviceDeleteSyncJob.enqueueMessageDeletes(setOf(deletedMessageRecord))
|
||||
}
|
||||
}.subscribeOn(Schedulers.io())
|
||||
|
||||
@@ -315,9 +315,6 @@ class Recipient(
|
||||
/** The notification channel, if both set and supported by the system. Otherwise null. */
|
||||
val notificationChannel: String? = if (!NotificationChannels.supported()) null else notificationChannelValue
|
||||
|
||||
/** The user's capability to handle synchronizing deletes across linked devices. */
|
||||
val deleteSyncCapability: Capability = capabilities.deleteSync
|
||||
|
||||
/** The user's capability to handle the new storage record encryption scheme. */
|
||||
val storageServiceEncryptionV2Capability: Capability
|
||||
get() = if (SignalStore.internal.forceSsre2Capability) Capability.SUPPORTED else capabilities.storageServiceEncryptionV2
|
||||
|
||||
@@ -104,9 +104,7 @@ public class AttachmentUtil {
|
||||
SignalDatabase.messages().deleteMessage(mmsId);
|
||||
} else {
|
||||
SignalDatabase.attachments().deleteAttachment(attachmentId);
|
||||
if (Recipient.self().getDeleteSyncCapability().isSupported()) {
|
||||
MultiDeviceDeleteSyncJob.enqueueAttachmentDelete(SignalDatabase.messages().getMessageRecordOrNull(mmsId), attachment);
|
||||
}
|
||||
MultiDeviceDeleteSyncJob.enqueueAttachmentDelete(SignalDatabase.messages().getMessageRecordOrNull(mmsId), attachment);
|
||||
}
|
||||
|
||||
return deletedMessageRecord;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceDeleteSyncJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask
|
||||
|
||||
@@ -46,10 +45,8 @@ object DeleteDialog {
|
||||
if (forceRemoteDelete) {
|
||||
builder.setPositiveButton(R.string.ConversationFragment_delete_for_everyone) { _, _ -> deleteForEveryone(messageRecords, emitter) }
|
||||
} else {
|
||||
val deleteSyncEnabled = Recipient.self().deleteSyncCapability.isSupported
|
||||
|
||||
val positiveButton = if (isNoteToSelfDelete) {
|
||||
if (deleteSyncEnabled) R.string.ConversationFragment_delete else R.string.ConversationFragment_delete_on_this_device
|
||||
R.string.ConversationFragment_delete
|
||||
} else {
|
||||
R.string.ConversationFragment_delete_for_me
|
||||
}
|
||||
@@ -60,9 +57,7 @@ object DeleteDialog {
|
||||
}.executeOnExecutor(SignalExecutors.BOUNDED)
|
||||
}
|
||||
|
||||
val canDeleteForEveryoneInNoteToSelf = isNoteToSelfDelete && SignalStore.account.hasLinkedDevices && !deleteSyncEnabled
|
||||
|
||||
if (MessageConstraintsUtil.isValidRemoteDeleteSend(messageRecords, System.currentTimeMillis()) && (!isNoteToSelfDelete || canDeleteForEveryoneInNoteToSelf)) {
|
||||
if (MessageConstraintsUtil.isValidRemoteDeleteSend(messageRecords, System.currentTimeMillis())) {
|
||||
builder.setNeutralButton(if (isNoteToSelfDelete) R.string.ConversationFragment_delete_everywhere else R.string.ConversationFragment_delete_for_everyone) { _, _ -> handleDeleteForEveryone(context, messageRecords, emitter) }
|
||||
}
|
||||
}
|
||||
@@ -120,9 +115,7 @@ object DeleteDialog {
|
||||
}
|
||||
}
|
||||
|
||||
if (Recipient.self().deleteSyncCapability.isSupported) {
|
||||
MultiDeviceDeleteSyncJob.enqueueMessageDeletes(messageRecords)
|
||||
}
|
||||
MultiDeviceDeleteSyncJob.enqueueMessageDeletes(messageRecords)
|
||||
|
||||
return threadDeleted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user