mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-08 20:38:33 +00:00
Don't include inactive groups when listing groups in common.
This commit is contained in:
parent
36d1e7c44a
commit
596c4b6e40
@ -228,12 +228,16 @@ public final class GroupDatabase extends Database {
|
|||||||
return getGroupsContainingMember(recipientId, true);
|
return getGroupsContainingMember(recipientId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
|
||||||
public @NonNull List<GroupRecord> getGroupsContainingMember(@NonNull RecipientId recipientId, boolean pushOnly) {
|
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();
|
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 table = TABLE_NAME + " INNER JOIN " + ThreadDatabase.TABLE_NAME + " ON " + TABLE_NAME + "." + RECIPIENT_ID + " = " + ThreadDatabase.TABLE_NAME + "." + ThreadDatabase.RECIPIENT_ID;
|
||||||
String query = MEMBERS + " LIKE ?";
|
String query = MEMBERS + " LIKE ?";
|
||||||
String[] args = new String[]{"%" + recipientId.serialize() + "%"};
|
String[] args = SqlUtil.buildArgs("%" + recipientId.serialize() + "%");
|
||||||
String orderBy = ThreadDatabase.TABLE_NAME + "." + ThreadDatabase.DATE + " DESC";
|
String orderBy = ThreadDatabase.TABLE_NAME + "." + ThreadDatabase.DATE + " DESC";
|
||||||
|
|
||||||
if (pushOnly) {
|
if (pushOnly) {
|
||||||
@ -241,6 +245,11 @@ public final class GroupDatabase extends Database {
|
|||||||
args = SqlUtil.appendArg(args, "0");
|
args = SqlUtil.appendArg(args, "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!includeInactive) {
|
||||||
|
query += " AND " + ACTIVE + " = ?";
|
||||||
|
args = SqlUtil.appendArg(args, "1");
|
||||||
|
}
|
||||||
|
|
||||||
List<GroupRecord> groups = new LinkedList<>();
|
List<GroupRecord> groups = new LinkedList<>();
|
||||||
|
|
||||||
try (Cursor cursor = database.query(table, null, query, args, null, null, orderBy)) {
|
try (Cursor cursor = database.query(table, null, query, args, null, null, orderBy)) {
|
||||||
|
@ -2290,7 +2290,7 @@ public class RecipientDatabase extends Database {
|
|||||||
|
|
||||||
// Groups
|
// Groups
|
||||||
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
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());
|
List<RecipientId> newMembers = new ArrayList<>(group.getMembers());
|
||||||
newMembers.remove(byE164);
|
newMembers.remove(byE164);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user