Search in sources :

Example 46 with DecryptedMember

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

the class GroupStateMapperTest method notices_changes_in_avatar_and_title_but_not_members_in_placeholder.

@Test
public void notices_changes_in_avatar_and_title_but_not_members_in_placeholder() {
    UUID newMemberUuid = UUID.randomUUID();
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
    DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(GroupStateMapper.PLACEHOLDER_REVISION).setTitle("Incorrect group title").setAvatar("Incorrect group avatar").addMembers(newMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(newMember).addMembers(existingMember).setTitle("Group Revision " + 8).setAvatar("Group Avatar " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(newMemberUuid)).addNewMembers(newMember).build());
    DecryptedGroupChange expectedChange = DecryptedGroupChange.newBuilder().setRevision(8).setNewTitle(DecryptedString.newBuilder().setValue("Group Revision " + 8)).setNewAvatar(DecryptedString.newBuilder().setValue("Group Avatar " + 8)).build();
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
    assertNotNull(log8.getGroup());
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(singletonList(new LocalGroupLogEntry(log8.getGroup(), expectedChange))));
    assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 47 with DecryptedMember

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

the class GroupStateMapperTest method clears_changes_duplicated_in_the_placeholder.

@Test
public void clears_changes_duplicated_in_the_placeholder() {
    UUID newMemberUuid = UUID.randomUUID();
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
    DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(GroupStateMapper.PLACEHOLDER_REVISION).setTitle("Group Revision " + 8).addMembers(newMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(newMember).addMembers(existingMember).setTitle("Group Revision " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(newMemberUuid)).addNewMembers(newMember).build());
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
    assertNotNull(log8.getGroup());
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(emptyList()));
    assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 48 with DecryptedMember

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

the class GroupManagerV2 method addedGroupVersion.

@WorkerThread
@NonNull
DecryptedGroup addedGroupVersion(@NonNull GroupMasterKey groupMasterKey) throws GroupNotAMemberException, IOException, GroupDoesNotExistException {
    GroupsV2StateProcessor.StateProcessorForGroup stateProcessorForGroup = new GroupsV2StateProcessor(context).forGroup(groupMasterKey);
    DecryptedGroup latest = stateProcessorForGroup.getCurrentGroupStateFromServer();
    if (latest.getRevision() == 0) {
        return latest;
    }
    Optional<DecryptedMember> selfInFullMemberList = DecryptedGroupUtil.findMemberByUuid(latest.getMembersList(), selfAci.uuid());
    if (!selfInFullMemberList.isPresent()) {
        return latest;
    }
    DecryptedGroup joinedVersion = stateProcessorForGroup.getSpecificVersionFromServer(selfInFullMemberList.get().getJoinedAtRevision());
    if (joinedVersion != null) {
        return joinedVersion;
    } else {
        Log.w(TAG, "Unable to retreive exact version joined at, using latest");
        return latest;
    }
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) GroupsV2StateProcessor(org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Example 49 with DecryptedMember

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

the class GroupStateMapperTest method clears_changes_duplicated_in_a_non_placeholder.

@Test
public void clears_changes_duplicated_in_a_non_placeholder() {
    UUID editorUuid = UUID.randomUUID();
    UUID newMemberUuid = UUID.randomUUID();
    DecryptedMember newMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMemberUuid)).build();
    DecryptedMember existingMember = DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(UUID.randomUUID())).build();
    DecryptedGroup currentState = DecryptedGroup.newBuilder().setRevision(8).setTitle("Group Revision " + 8).addMembers(existingMember).build();
    ServerGroupLogEntry log8 = new ServerGroupLogEntry(DecryptedGroup.newBuilder().setRevision(8).addMembers(existingMember).addMembers(newMember).setTitle("Group Revision " + 8).build(), DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(editorUuid)).addNewMembers(existingMember).addNewMembers(newMember).build());
    DecryptedGroupChange expectedChange = DecryptedGroupChange.newBuilder().setRevision(8).setEditor(UuidUtil.toByteString(editorUuid)).addNewMembers(newMember).build();
    AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, singletonList(log8)), LATEST);
    assertNotNull(log8.getGroup());
    assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(singletonList(new LocalGroupLogEntry(log8.getGroup(), expectedChange))));
    assertNewState(new GlobalGroupState(log8.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState());
    assertEquals(log8.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState());
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 50 with DecryptedMember

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

the class GroupsV2UpdateMessageProducer method describeUnknownEditorPromotePending.

private void describeUnknownEditorPromotePending(@NonNull DecryptedGroupChange change, @NonNull List<UpdateDescription> updates) {
    for (DecryptedMember newMember : change.getPromotePendingMembersList()) {
        ByteString uuid = newMember.getUuid();
        boolean newMemberIsYou = uuid.equals(selfUuidBytes);
        if (newMemberIsYou) {
            updates.add(updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group), R.drawable.ic_update_group_add_16));
        } else {
            updates.add(updateDescription(uuid, newMemberName -> context.getString(R.string.MessageRecord_s_joined_the_group, newMemberName), R.drawable.ic_update_group_add_16));
        }
    }
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) NonNull(androidx.annotation.NonNull) StringUtil(org.thoughtcrime.securesms.util.StringUtil) WorkerThread(androidx.annotation.WorkerThread) GV2AccessLevelUtil(org.thoughtcrime.securesms.groups.GV2AccessLevelUtil) ExpirationUtil(org.thoughtcrime.securesms.util.ExpirationUtil) DrawableRes(androidx.annotation.DrawableRes) AccessControl(org.signal.storageservice.protos.groups.AccessControl) R(org.thoughtcrime.securesms.R) Member(org.signal.storageservice.protos.groups.Member) DecryptedModifyMemberRole(org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) DecryptedApproveMember(org.signal.storageservice.protos.groups.local.DecryptedApproveMember) LinkedList(java.util.LinkedList) DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) ACI(org.whispersystems.signalservice.api.push.ACI) DecryptedGroupUtil(org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil) EnabledState(org.signal.storageservice.protos.groups.local.EnabledState) UuidUtil(org.whispersystems.signalservice.api.util.UuidUtil) DecryptedPendingMember(org.signal.storageservice.protos.groups.local.DecryptedPendingMember) UUID(java.util.UUID) Optional(org.whispersystems.libsignal.util.guava.Optional) ByteString(com.google.protobuf.ByteString) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) List(java.util.List) Nullable(androidx.annotation.Nullable) DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval) ServiceId(org.whispersystems.signalservice.api.push.ServiceId) Collections(java.util.Collections) ByteString(com.google.protobuf.ByteString) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember)

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