Don't include inactive groups when listing groups in common.

master
Greyson Parrelli 2020-08-06 16:23:25 -04:00
parent 36d1e7c44a
commit 596c4b6e40
2 changed files with 12 additions and 3 deletions

View File

@ -228,12 +228,16 @@ public final class GroupDatabase extends Database {
return getGroupsContainingMember(recipientId, true);
}
@WorkerThread
public @NonNull List<GroupRecord> getGroupsContainingMember(@NonNull RecipientId recipientId, boolean pushOnly) {
return getGroupsContainingMember(recipientId, pushOnly, false);
}
@WorkerThread
public @NonNull List<GroupRecord> getGroupsContainingMember(@NonNull RecipientId recipientId, boolean pushOnly, boolean includeInactive) {
SQLiteDatabase database = databaseHelper.getReadableDatabase();
String table = TABLE_NAME + " INNER JOIN " + ThreadDatabase.TABLE_NAME + " ON " + TABLE_NAME + "." + RECIPIENT_ID + " = " + ThreadDatabase.TABLE_NAME + "." + ThreadDatabase.RECIPIENT_ID;
String query = MEMBERS + " LIKE ?";
String[] args = new String[]{"%" + recipientId.serialize() + "%"};
String[] args = SqlUtil.buildArgs("%" + recipientId.serialize() + "%");
String orderBy = ThreadDatabase.TABLE_NAME + "." + ThreadDatabase.DATE + " DESC";
if (pushOnly) {
@ -241,6 +245,11 @@ public final class GroupDatabase extends Database {
args = SqlUtil.appendArg(args, "0");
}
if (!includeInactive) {
query += " AND " + ACTIVE + " = ?";
args = SqlUtil.appendArg(args, "1");
}
List<GroupRecord> groups = new LinkedList<>();
try (Cursor cursor = database.query(table, null, query, args, null, null, orderBy)) {

View File

@ -2290,7 +2290,7 @@ public class RecipientDatabase extends Database {
// Groups
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
for (GroupDatabase.GroupRecord group : groupDatabase.getGroupsContainingMember(byE164, false)) {
for (GroupDatabase.GroupRecord group : groupDatabase.getGroupsContainingMember(byE164, false, true)) {
List<RecipientId> newMembers = new ArrayList<>(group.getMembers());
newMembers.remove(byE164);