kopia lustrzana https://github.com/ryukoposting/Signal-Android
Implement proper group story reply deletion for remotely deleted group stories.
rodzic
9afeb206fc
commit
33d60ebe14
|
@ -202,6 +202,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
public abstract int deleteStoriesOlderThan(long timestamp);
|
||||
public abstract @NonNull MessageDatabase.Reader getUnreadStories(@NonNull RecipientId recipientId, int limit);
|
||||
public abstract @Nullable ParentStoryId.GroupReply getParentStoryIdForGroupReply(long messageId);
|
||||
public abstract void deleteGroupStoryReplies(long parentStoryId);
|
||||
|
||||
public abstract @NonNull StoryViewState getStoryViewState(@NonNull RecipientId recipientId);
|
||||
public abstract void updateViewedStories(@NonNull Set<SyncMessageId> syncMessageIds);
|
||||
|
|
|
@ -837,6 +837,14 @@ public class MmsDatabase extends MessageDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGroupStoryReplies(long parentStoryId) {
|
||||
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
|
||||
String[] args = SqlUtil.buildArgs(parentStoryId);
|
||||
|
||||
db.delete(TABLE_NAME, PARENT_STORY_ID + " = ?", args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteStoriesOlderThan(long timestamp) {
|
||||
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
|
||||
|
@ -1256,6 +1264,7 @@ public class MmsDatabase extends MessageDatabase {
|
|||
SignalDatabase.mentions().deleteMentionsForMessage(messageId);
|
||||
SignalDatabase.messageLog().deleteAllRelatedToMessage(messageId, true);
|
||||
SignalDatabase.reactions().deleteReactions(new MessageId(messageId, true));
|
||||
deleteGroupStoryReplies(messageId);
|
||||
|
||||
threadId = getThreadIdForMessage(messageId);
|
||||
SignalDatabase.threads().update(threadId, false);
|
||||
|
|
|
@ -1477,6 +1477,11 @@ public class SmsDatabase extends MessageDatabase {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteGroupStoryReplies(long parentStoryId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageRecord getMessageRecord(long messageId) throws NoSuchMessageException {
|
||||
return getSmsMessage(messageId);
|
||||
|
|
|
@ -198,8 +198,9 @@ object SignalDatabaseMigrations {
|
|||
private const val QUOTE_TYPE = 142
|
||||
private const val STORY_SYNCS = 143
|
||||
private const val GROUP_STORY_NOTIFICATIONS = 144
|
||||
private const val GROUP_STORY_REPLY_CLEANUP = 145
|
||||
|
||||
const val DATABASE_VERSION = 144
|
||||
const val DATABASE_VERSION = 145
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
@ -2572,6 +2573,17 @@ object SignalDatabaseMigrations {
|
|||
if (oldVersion < GROUP_STORY_NOTIFICATIONS) {
|
||||
db.execSQL("UPDATE mms SET read = 1 WHERE parent_story_id > 0")
|
||||
}
|
||||
|
||||
if (oldVersion < GROUP_STORY_REPLY_CLEANUP) {
|
||||
db.execSQL(
|
||||
"""
|
||||
DELETE FROM mms
|
||||
WHERE
|
||||
parent_story_id > 0 AND
|
||||
parent_story_id NOT IN (SELECT _id FROM mms WHERE remote_deleted = 0)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
|
Ładowanie…
Reference in New Issue