mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 10:48:34 +00:00
Detect if group v2 is active from membership.
This commit is contained in:
parent
befb4939d5
commit
56551025e9
@ -391,11 +391,14 @@ public final class GroupDatabase extends Database {
|
|||||||
RecipientId groupRecipientId = recipientDatabase.getOrInsertFromGroupId(groupId);
|
RecipientId groupRecipientId = recipientDatabase.getOrInsertFromGroupId(groupId);
|
||||||
String title = decryptedGroup.getTitle();
|
String title = decryptedGroup.getTitle();
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
|
UUID uuid = Recipient.self().getUuid().get();
|
||||||
|
|
||||||
contentValues.put(TITLE, title);
|
contentValues.put(TITLE, title);
|
||||||
contentValues.put(V2_REVISION, decryptedGroup.getVersion());
|
contentValues.put(V2_REVISION, decryptedGroup.getVersion());
|
||||||
contentValues.put(V2_DECRYPTED_GROUP, decryptedGroup.toByteArray());
|
contentValues.put(V2_DECRYPTED_GROUP, decryptedGroup.toByteArray());
|
||||||
contentValues.put(MEMBERS, serializeV2GroupMembers(decryptedGroup));
|
contentValues.put(MEMBERS, serializeV2GroupMembers(decryptedGroup));
|
||||||
|
contentValues.put(ACTIVE, DecryptedGroupUtil.findMemberByUuid(decryptedGroup.getMembersList(), uuid).isPresent() ||
|
||||||
|
DecryptedGroupUtil.findPendingByUuid(decryptedGroup.getPendingMembersList(), uuid).isPresent() ? 1 : 0);
|
||||||
|
|
||||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
|
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
|
||||||
GROUP_ID + " = ?",
|
GROUP_ID + " = ?",
|
||||||
|
@ -140,16 +140,16 @@ final class GroupsV2UpdateMessageProducer {
|
|||||||
boolean editorIsYou = change.getEditor().equals(selfUuidBytes);
|
boolean editorIsYou = change.getEditor().equals(selfUuidBytes);
|
||||||
|
|
||||||
for (ByteString member : change.getDeleteMembersList()) {
|
for (ByteString member : change.getDeleteMembersList()) {
|
||||||
boolean newMemberIsYou = member.equals(selfUuidBytes);
|
boolean removedMemberIsYou = member.equals(selfUuidBytes);
|
||||||
|
|
||||||
if (editorIsYou) {
|
if (editorIsYou) {
|
||||||
if (newMemberIsYou) {
|
if (removedMemberIsYou) {
|
||||||
updates.add(context.getString(R.string.MessageRecord_you_left_the_group));
|
updates.add(context.getString(R.string.MessageRecord_you_left_the_group));
|
||||||
} else {
|
} else {
|
||||||
updates.add(context.getString(R.string.MessageRecord_you_removed_s, describe(member)));
|
updates.add(context.getString(R.string.MessageRecord_you_removed_s, describe(member)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (newMemberIsYou) {
|
if (removedMemberIsYou) {
|
||||||
updates.add(context.getString(R.string.MessageRecord_s_removed_you_from_the_group, describe(change.getEditor())));
|
updates.add(context.getString(R.string.MessageRecord_s_removed_you_from_the_group, describe(change.getEditor())));
|
||||||
} else {
|
} else {
|
||||||
if (member.equals(change.getEditor())) {
|
if (member.equals(change.getEditor())) {
|
||||||
|
@ -265,13 +265,8 @@ final class GroupManagerV2 {
|
|||||||
throws GroupChangeFailedException, GroupInsufficientRightsException, IOException, GroupNotAMemberException
|
throws GroupChangeFailedException, GroupInsufficientRightsException, IOException, GroupNotAMemberException
|
||||||
{
|
{
|
||||||
Recipient recipient = Recipient.resolved(recipientId);
|
Recipient recipient = Recipient.resolved(recipientId);
|
||||||
GroupManager.GroupActionResult result = commitChangeWithConflictResolution(groupOperations.createRemoveMembersChange(Collections.singleton(recipient.getUuid().get())));
|
|
||||||
|
|
||||||
if (recipient.isLocalNumber()) {
|
return commitChangeWithConflictResolution(groupOperations.createRemoveMembersChange(Collections.singleton(recipient.getUuid().get())));
|
||||||
groupDatabase.setActive(groupId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
Loading…
x
Reference in New Issue
Block a user