mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add Delete for Me sync support.
This commit is contained in:
@@ -69,22 +69,26 @@ public class AttachmentUtil {
|
||||
/**
|
||||
* Deletes the specified attachment. If its the only attachment for its linked message, the entire
|
||||
* message is deleted.
|
||||
*
|
||||
* @return message record of deleted message if a message is deleted
|
||||
*/
|
||||
@WorkerThread
|
||||
public static void deleteAttachment(@NonNull Context context,
|
||||
@NonNull DatabaseAttachment attachment)
|
||||
{
|
||||
public static @Nullable MessageRecord deleteAttachment(@NonNull DatabaseAttachment attachment) {
|
||||
AttachmentId attachmentId = attachment.attachmentId;
|
||||
long mmsId = attachment.mmsId;
|
||||
int attachmentCount = SignalDatabase.attachments()
|
||||
.getAttachmentsForMessage(mmsId)
|
||||
.size();
|
||||
|
||||
MessageRecord deletedMessageRecord = null;
|
||||
if (attachmentCount <= 1) {
|
||||
deletedMessageRecord = SignalDatabase.messages().getMessageRecordOrNull(mmsId);
|
||||
SignalDatabase.messages().deleteMessage(mmsId);
|
||||
} else {
|
||||
SignalDatabase.attachments().deleteAttachment(attachmentId);
|
||||
}
|
||||
|
||||
return deletedMessageRecord;
|
||||
}
|
||||
|
||||
private static boolean isNonDocumentType(String contentType) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceDeleteSendSyncJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask
|
||||
@@ -100,13 +101,19 @@ object DeleteDialog {
|
||||
R.string.ConversationFragment_deleting_messages
|
||||
) {
|
||||
override fun doInBackground(vararg params: Void?): Boolean {
|
||||
return messageRecords.map { record ->
|
||||
if (record.isMms) {
|
||||
SignalDatabase.messages.deleteMessage(record.id)
|
||||
} else {
|
||||
SignalDatabase.messages.deleteMessage(record.id)
|
||||
var threadDeleted = false
|
||||
|
||||
messageRecords.forEach { record ->
|
||||
if (SignalDatabase.messages.deleteMessage(record.id)) {
|
||||
threadDeleted = true
|
||||
}
|
||||
}.any { it }
|
||||
}
|
||||
|
||||
if (FeatureFlags.deleteSyncEnabled()) {
|
||||
MultiDeviceDeleteSendSyncJob.enqueueMessageDeletes(messageRecords)
|
||||
}
|
||||
|
||||
return threadDeleted
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Boolean?) {
|
||||
|
||||
@@ -131,6 +131,7 @@ public final class FeatureFlags {
|
||||
private static final String LIBSIGNAL_WEB_SOCKET_ENABLED = "android.libsignalWebSocketEnabled";
|
||||
private static final String RESTORE_POST_REGISTRATION = "android.registration.restorePostRegistration";
|
||||
private static final String LIBSIGNAL_WEB_SOCKET_SHADOW_PCT = "android.libsignalWebSocketShadowingPercentage";
|
||||
private static final String DELETE_SYNC_SEND_RECEIVE = "android.deleteSyncSendReceive";
|
||||
|
||||
/**
|
||||
* We will only store remote values for flags in this set. If you want a flag to be controllable
|
||||
@@ -211,7 +212,8 @@ public final class FeatureFlags {
|
||||
LINKED_DEVICE_LIFESPAN_SECONDS,
|
||||
CAMERAX_CUSTOM_CONTROLLER,
|
||||
LIBSIGNAL_WEB_SOCKET_ENABLED,
|
||||
LIBSIGNAL_WEB_SOCKET_SHADOW_PCT
|
||||
LIBSIGNAL_WEB_SOCKET_SHADOW_PCT,
|
||||
DELETE_SYNC_SEND_RECEIVE
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -287,7 +289,8 @@ public final class FeatureFlags {
|
||||
CDSI_LIBSIGNAL_NET,
|
||||
RX_MESSAGE_SEND,
|
||||
LINKED_DEVICE_LIFESPAN_SECONDS,
|
||||
CAMERAX_CUSTOM_CONTROLLER
|
||||
CAMERAX_CUSTOM_CONTROLLER,
|
||||
DELETE_SYNC_SEND_RECEIVE
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -766,6 +769,11 @@ public final class FeatureFlags {
|
||||
return Math.max(0, Math.min(value, 100));
|
||||
}
|
||||
|
||||
/** Whether or not to delete syncing is enabled. */
|
||||
public static boolean deleteSyncEnabled() {
|
||||
return getBoolean(DELETE_SYNC_SEND_RECEIVE, false);
|
||||
}
|
||||
|
||||
/** Only for rendering debug info. */
|
||||
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
|
||||
return new TreeMap<>(REMOTE_VALUES);
|
||||
|
||||
Reference in New Issue
Block a user