Add support for GV1->GV2 forced migration.

This commit is contained in:
Greyson Parrelli
2020-11-12 12:32:10 -05:00
committed by GitHub
parent 554aa1ddf0
commit 2dace38d43
15 changed files with 117 additions and 32 deletions

View File

@@ -220,7 +220,7 @@ public final class GroupDatabase extends Database {
return noMetadata && noMembers;
}
public Reader getGroupsFilteredByTitle(String constraint, boolean includeInactive) {
public Reader getGroupsFilteredByTitle(String constraint, boolean includeInactive, boolean excludeV1) {
String query;
String[] queryArgs;
@@ -232,6 +232,10 @@ public final class GroupDatabase extends Database {
queryArgs = new String[]{"%" + constraint + "%", "1"};
}
if (excludeV1) {
query += " AND " + EXPECTED_V2_ID + " IS NULL";
}
Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, null, query, queryArgs, null, null, TITLE + " COLLATE NOCASE ASC");
return new Reader(cursor);

View File

@@ -93,7 +93,7 @@ public class RecipientDatabase extends Database {
public static final String PHONE = "phone";
public static final String EMAIL = "email";
static final String GROUP_ID = "group_id";
private static final String GROUP_TYPE = "group_type";
static final String GROUP_TYPE = "group_type";
private static final String BLOCKED = "blocked";
private static final String MESSAGE_RINGTONE = "message_ringtone";
private static final String MESSAGE_VIBRATE = "message_vibrate";

View File

@@ -545,11 +545,11 @@ public class ThreadDatabase extends Database {
return cursor;
}
public Cursor getRecentConversationList(int limit, boolean includeInactiveGroups) {
return getRecentConversationList(limit, includeInactiveGroups, false);
public Cursor getRecentConversationList(int limit, boolean includeInactiveGroups, boolean hideV1Groups) {
return getRecentConversationList(limit, includeInactiveGroups, false, hideV1Groups);
}
public Cursor getRecentConversationList(int limit, boolean includeInactiveGroups, boolean groupsOnly) {
public Cursor getRecentConversationList(int limit, boolean includeInactiveGroups, boolean groupsOnly, boolean hideV1Groups) {
SQLiteDatabase db = databaseHelper.getReadableDatabase();
String query = !includeInactiveGroups ? MESSAGE_COUNT + " != 0 AND (" + GroupDatabase.TABLE_NAME + "." + GroupDatabase.ACTIVE + " IS NULL OR " + GroupDatabase.TABLE_NAME + "." + GroupDatabase.ACTIVE + " = 1)"
: MESSAGE_COUNT + " != 0";
@@ -558,6 +558,10 @@ public class ThreadDatabase extends Database {
query += " AND " + RecipientDatabase.TABLE_NAME + "." + RecipientDatabase.GROUP_ID + " NOT NULL";
}
if (hideV1Groups) {
query += " AND " + RecipientDatabase.TABLE_NAME + "." + RecipientDatabase.GROUP_TYPE + " != " + RecipientDatabase.GroupType.SIGNAL_V1.getId();
}
return db.rawQuery(createQuery(query, 0, limit, true), null);
}