mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
delete outgoing message for linked device
This commit is contained in:
parent
064e509992
commit
ee3e9ae17f
@ -19,6 +19,7 @@ import org.session.libsignal.utilities.guava.Optional
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase
|
||||
import org.thoughtcrime.securesms.database.Database
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints
|
||||
@ -167,13 +168,9 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
|
||||
}
|
||||
|
||||
override fun deleteMessage(messageID: Long, isSms: Boolean) {
|
||||
if (isSms) {
|
||||
val db = DatabaseFactory.getSmsDatabase(context)
|
||||
db.deleteMessage(messageID)
|
||||
} else {
|
||||
val db = DatabaseFactory.getMmsDatabase(context)
|
||||
db.delete(messageID)
|
||||
}
|
||||
val messagingDatabase: MessagingDatabase = if (isSms) DatabaseFactory.getSmsDatabase(context)
|
||||
else DatabaseFactory.getMmsDatabase(context)
|
||||
messagingDatabase.deleteMessage(messageID)
|
||||
DatabaseFactory.getLokiMessageDatabase(context).deleteMessage(messageID, isSms)
|
||||
DatabaseFactory.getLokiMessageDatabase(context).deleteMessageServerHash(messageID)
|
||||
}
|
||||
@ -182,14 +179,12 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
|
||||
val database = DatabaseFactory.getMmsSmsDatabase(context)
|
||||
val address = Address.fromSerialized(author)
|
||||
val message = database.getMessageFor(timestamp, address)!!
|
||||
if (message.isMms) {
|
||||
val mmsDatabase = DatabaseFactory.getMmsDatabase(context)
|
||||
mmsDatabase.markAsDeleted(message.id, message.isRead)
|
||||
} else {
|
||||
val smsDatabase = DatabaseFactory.getSmsDatabase(context)
|
||||
smsDatabase.markAsDeleted(message.id, message.isRead)
|
||||
val messagingDatabase: MessagingDatabase = if (message.isMms) DatabaseFactory.getMmsDatabase(context)
|
||||
else DatabaseFactory.getSmsDatabase(context)
|
||||
messagingDatabase.markAsDeleted(message.id, message.isRead)
|
||||
if (message.isOutgoing) {
|
||||
messagingDatabase.deleteMessage(message.id)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getServerHashForMessage(messageID: Long): String? {
|
||||
|
@ -40,6 +40,8 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
|
||||
|
||||
public abstract void markAsDeleted(long messageId, boolean read);
|
||||
|
||||
public abstract boolean deleteMessage(long messageId);
|
||||
|
||||
public void addMismatchedIdentity(long messageId, Address address, IdentityKey identityKey) {
|
||||
try {
|
||||
addToDocument(messageId, MISMATCHED_IDENTITIES,
|
||||
|
@ -923,7 +923,8 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
public boolean delete(long messageId) {
|
||||
@Override
|
||||
public boolean deleteMessage(long messageId) {
|
||||
long threadId = getThreadIdForMessage(messageId);
|
||||
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
|
||||
ThreadUtils.queue(() -> attachmentDatabase.deleteAttachmentsForMessage(messageId));
|
||||
@ -1050,7 +1051,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
cursor = db.query(TABLE_NAME, new String[] {ID}, where, null, null, null, null);
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
delete(cursor.getLong(0));
|
||||
deleteMessage(cursor.getLong(0));
|
||||
}
|
||||
|
||||
} finally {
|
||||
@ -1076,7 +1077,7 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
Log.i("MmsDatabase", "Trimming: " + cursor.getLong(0));
|
||||
delete(cursor.getLong(0));
|
||||
deleteMessage(cursor.getLong(0));
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
@ -529,6 +529,7 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteMessage(long messageId) {
|
||||
Log.i("MessageDatabase", "Deleting: " + messageId);
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
|
@ -229,7 +229,7 @@ public class ExpiringMessageManager implements SSKEnvironment.MessageExpirationM
|
||||
}
|
||||
|
||||
if (expiredMessage != null) {
|
||||
if (expiredMessage.mms) mmsDatabase.delete(expiredMessage.id);
|
||||
if (expiredMessage.mms) mmsDatabase.deleteMessage(expiredMessage.id);
|
||||
else smsDatabase.deleteMessage(expiredMessage.id);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class AttachmentUtil {
|
||||
.size();
|
||||
|
||||
if (attachmentCount <= 1) {
|
||||
DatabaseFactory.getMmsDatabase(context).delete(mmsId);
|
||||
DatabaseFactory.getMmsDatabase(context).deleteMessage(mmsId);
|
||||
} else {
|
||||
DatabaseFactory.getAttachmentDatabase(context).deleteAttachment(attachmentId);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user