Ensure reactions are deleted for remote-deleted messages.

We were doing this for MmsDatabase, but not SmsDatabase. Includes a
migration to cleanup any existing bad state.
master
Greyson Parrelli 2020-10-08 10:21:57 -04:00
parent 8d060837ad
commit 5cdc5bc441
2 changed files with 10 additions and 1 deletions

View File

@ -373,6 +373,7 @@ public class SmsDatabase extends MessageDatabase {
ContentValues values = new ContentValues();
values.put(REMOTE_DELETED, 1);
values.putNull(BODY);
values.putNull(REACTIONS);
db.update(TABLE_NAME, values, ID_WHERE, new String[] { String.valueOf(id) });
long threadId = getThreadIdForMessage(id);

View File

@ -64,6 +64,7 @@ import org.thoughtcrime.securesms.util.SqlUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Triple;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.signalservice.internal.push.SignalServiceProtos;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -155,8 +156,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int STICKER_CONTENT_TYPE_CLEANUP = 75;
private static final int MENTION_CLEANUP = 76;
private static final int MENTION_CLEANUP_V2 = 77;
private static final int REACTION_CLEANUP = 78;
private static final int DATABASE_VERSION = 77;
private static final int DATABASE_VERSION = 78;
private static final String DATABASE_NAME = "signal.db";
private final Context context;
@ -1123,6 +1125,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
}
}
if (oldVersion < REACTION_CLEANUP) {
ContentValues values = new ContentValues();
values.putNull("reactions");
db.update("sms", values, "remote_deleted = ?", new String[] { "1" });
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();