Fix remote delete for private stories.

This commit is contained in:
Rashad Sookram
2022-03-16 17:11:16 -04:00
committed by Cody Henthorne
parent b5e0991f5e
commit 6b6e9e92e8
7 changed files with 54 additions and 25 deletions

View File

@@ -189,6 +189,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
public abstract @NonNull Reader getAllStoriesFor(@NonNull RecipientId recipientId);
public abstract @NonNull MessageId getStoryId(@NonNull RecipientId authorId, long sentTimestamp) throws NoSuchMessageException;
public abstract int getNumberOfStoryReplies(long parentStoryId);
public abstract boolean containsStories(long threadId);
public abstract boolean hasSelfReplyInStory(long parentStoryId);
public abstract @NonNull Cursor getStoryReplies(long parentStoryId);
public abstract long getUnreadStoryCount();

View File

@@ -708,6 +708,18 @@ public class MmsDatabase extends MessageDatabase {
}
}
@Override
public boolean containsStories(long threadId) {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
String[] columns = new String[]{"1"};
String where = THREAD_ID_WHERE + " AND " + STORY_TYPE + " > 0";
String[] whereArgs = SqlUtil.buildArgs(threadId);
try (Cursor cursor = db.query(TABLE_NAME, columns, where, whereArgs, null, null, null, "1")) {
return cursor != null && cursor.moveToNext();
}
}
@Override
public boolean hasSelfReplyInStory(long parentStoryId) {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();

View File

@@ -1424,6 +1424,11 @@ public class SmsDatabase extends MessageDatabase {
throw new UnsupportedOperationException();
}
@Override
public boolean containsStories(long threadId) {
throw new UnsupportedOperationException();
}
@Override
public boolean hasSelfReplyInStory(long parentStoryId) {
throw new UnsupportedOperationException();

View File

@@ -1308,7 +1308,7 @@ public class ThreadDatabase extends Database {
try {
record = mmsSmsDatabase.getConversationSnippet(threadId);
} catch (NoSuchMessageException e) {
if (allowDeletion) {
if (allowDeletion && !SignalDatabase.mms().containsStories(threadId)) {
deleteConversation(threadId);
}
return true;