Search in sources :

Example 41 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.

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);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

Example 42 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.

the class DecryptedGroupUtil method applyModifyMemberProfileKeyActions.

private static void applyModifyMemberProfileKeyActions(DecryptedGroup.Builder builder, List<DecryptedMember> modifiedProfileKeysList) throws NotAbleToApplyGroupV2ChangeException {
    for (DecryptedMember modifyProfileKey : modifiedProfileKeysList) {
        int index = indexOfUuid(builder.getMembersList(), modifyProfileKey.getUuid());
        if (index == -1) {
            throw new NotAbleToApplyGroupV2ChangeException();
        }
        builder.setMembers(index, withNewProfileKey(builder.getMembers(index), modifyProfileKey.getProfileKey()));
    }
}
Also used : DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

Example 43 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.

the class DecryptedGroupUtil method applyAddMemberAction.

private static void applyAddMemberAction(DecryptedGroup.Builder builder, List<DecryptedMember> newMembersList) {
    if (newMembersList.isEmpty())
        return;
    LinkedHashMap<ByteString, DecryptedMember> members = new LinkedHashMap<>();
    for (DecryptedMember member : builder.getMembersList()) {
        members.put(member.getUuid(), member);
    }
    for (DecryptedMember member : newMembersList) {
        members.put(member.getUuid(), member);
    }
    builder.clearMembers();
    builder.addAllMembers(members.values());
    removePendingAndRequestingMembersNowInGroup(builder);
}
Also used : ByteString(com.google.protobuf.ByteString) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) LinkedHashMap(java.util.LinkedHashMap)

Example 44 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.

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);
        }
    }
}
Also used : DecryptedModifyMemberRole(org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

Example 45 with DecryptedMember

use of org.signal.storageservice.protos.groups.local.DecryptedMember in project Signal-Android by WhisperSystems.

the class GroupStateMapperTest method updates_with_a_server_mismatch_inserts_additional_update.

@Test
public void updates_with_a_server_mismatch_inserts_additional_update() {
    DecryptedGroup currentState = state(6);
    ServerGroupLogEntry log7 = serverLogEntry(7);
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup state7b = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).build();
    DecryptedGroup state8 = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).addMembers(newMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(state8, change(8));
    ServerGroupLogEntry log9 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(9).addMembers(newMember).setTitle("Group Revision " + 9).build(), change(9));
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log7, log8, log9)), LATEST);
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log7), new LocalGroupLogEntry(state7b, log8.getChange()), new LocalGroupLogEntry(state8, DecryptedGroupChange.newBuilder().setRevision(8).addNewMembers(newMember).build()), asLocal(log9))));
    assertNewState(new GlobalGroupState(log9.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log9.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Aggregations

DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)80 Test (org.junit.Test)54 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)48 UUID (java.util.UUID)32 DecryptedPendingMember (org.signal.storageservice.protos.groups.local.DecryptedPendingMember)20 ProfileKey (org.signal.zkgroup.profiles.ProfileKey)14 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)14 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)14 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)14 ByteString (com.google.protobuf.ByteString)12 DecryptedRequestingMember (org.signal.storageservice.protos.groups.local.DecryptedRequestingMember)12 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)10 NonNull (androidx.annotation.NonNull)6 WorkerThread (androidx.annotation.WorkerThread)6 DecryptedModifyMemberRole (org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole)6 Context (android.content.Context)4 DrawableRes (androidx.annotation.DrawableRes)4 Nullable (androidx.annotation.Nullable)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4