use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_new_pending_member_already_pending.
@Test
public void apply_new_pending_member_already_pending() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedPendingMember pending = pendingMember(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewPendingMembers(pending).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addPendingMembers(pending).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil method removeMember.
/**
* Removes the uuid from the full members of a group.
* <p>
* Generally not expected to have to do this, just in the case of leaving a group where you cannot
* get the new group state as you are not in the group any longer.
*/
public static DecryptedGroup removeMember(DecryptedGroup group, UUID uuid, int revision) {
DecryptedGroup.Builder builder = DecryptedGroup.newBuilder(group);
ByteString uuidString = UuidUtil.toByteString(uuid);
boolean removed = false;
ArrayList<DecryptedMember> decryptedMembers = new ArrayList<>(builder.getMembersList());
Iterator<DecryptedMember> membersList = decryptedMembers.iterator();
while (membersList.hasNext()) {
if (uuidString.equals(membersList.next().getUuid())) {
membersList.remove();
removed = true;
}
}
if (removed) {
return builder.clearMembers().addAllMembers(decryptedMembers).setRevision(revision).build();
} else {
return group;
}
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class GroupChangeUtil method resolveField5ModifyMemberRoles.
private static void resolveField5ModifyMemberRoles(DecryptedGroupChange conflictingChange, ChangeSetModifier result, HashMap<ByteString, DecryptedMember> fullMembersByUuid) {
List<DecryptedModifyMemberRole> modifyRolesList = conflictingChange.getModifyMemberRolesList();
for (int i = modifyRolesList.size() - 1; i >= 0; i--) {
DecryptedModifyMemberRole modifyRoleAction = modifyRolesList.get(i);
DecryptedMember memberInGroup = fullMembersByUuid.get(modifyRoleAction.getUuid());
if (memberInGroup == null || memberInGroup.getRole() == modifyRoleAction.getRole()) {
result.removeModifyMemberRoles(i);
}
}
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupChangeActionsBuilderChangeSetModifier method moveAddToPromote.
@Override
public void moveAddToPromote(int i) {
DecryptedMember addMemberAction = result.getNewMembersList().get(i);
result.removeNewMembers(i);
result.addPromotePendingMembers(addMemberAction);
}
use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by signalapp.
the class DecryptedGroupChangeActionsBuilderChangeSetModifier method moveAddRequestingMembersToPromote.
@Override
public void moveAddRequestingMembersToPromote(int i) {
DecryptedRequestingMember addMemberAction = result.getNewRequestingMembersList().get(i);
result.removeNewRequestingMembers(i);
DecryptedMember build = DecryptedMember.newBuilder().setUuid(addMemberAction.getUuid()).setProfileKey(addMemberAction.getProfileKey()).setRole(Member.Role.DEFAULT).build();
result.addPromotePendingMembers(0, build);
}
Aggregations