Search in sources :

Example 36 with DecryptedMember

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

the class DecryptedGroupUtil_apply_Test method cant_apply_modify_member_profile_keys_if_member_not_in_group.

@Test(expected = NotAbleToApplyGroupV2ChangeException.class)
public void cant_apply_modify_member_profile_keys_if_member_not_in_group() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey1 = randomProfileKey();
    ProfileKey profileKey2a = randomProfileKey();
    ProfileKey profileKey2b = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
    DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
    DecryptedMember member2b = member(UUID.randomUUID(), profileKey2b);
    DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
}
Also used : ProtoTestUtils.withProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) ProtoTestUtils.newProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 37 with DecryptedMember

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

the class DecryptedGroupUtil_apply_Test method apply_new_member.

@Test
public void apply_new_member() throws NotAbleToApplyGroupV2ChangeException {
    DecryptedMember member1 = member(UUID.randomUUID());
    DecryptedMember member2 = member(UUID.randomUUID());
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(member2).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).build(), newGroup);
}
Also used : DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 38 with DecryptedMember

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

the class GroupsV2UpdateMessageProducer method describePromotePending.

private void describePromotePending(@NonNull DecryptedGroupChange change, @NonNull List<UpdateDescription> updates) {
    boolean editorIsYou = change.getEditor().equals(selfUuidBytes);
    for (DecryptedMember newMember : change.getPromotePendingMembersList()) {
        ByteString uuid = newMember.getUuid();
        boolean newMemberIsYou = uuid.equals(selfUuidBytes);
        if (editorIsYou) {
            if (newMemberIsYou) {
                updates.add(updateDescription(context.getString(R.string.MessageRecord_you_accepted_invite), R.drawable.ic_update_group_accept_16));
            } else {
                updates.add(updateDescription(uuid, newPromotedMember -> context.getString(R.string.MessageRecord_you_added_invited_member_s, newPromotedMember), R.drawable.ic_update_group_add_16));
            }
        } else {
            if (newMemberIsYou) {
                updates.add(updateDescription(change.getEditor(), editor -> context.getString(R.string.MessageRecord_s_added_you, editor), R.drawable.ic_update_group_add_16));
            } else {
                if (uuid.equals(change.getEditor())) {
                    updates.add(updateDescription(uuid, newAcceptedMember -> context.getString(R.string.MessageRecord_s_accepted_invite, newAcceptedMember), R.drawable.ic_update_group_accept_16));
                } else {
                    updates.add(updateDescription(change.getEditor(), uuid, (editor, newAcceptedMember) -> context.getString(R.string.MessageRecord_s_added_invited_member_s, editor, newAcceptedMember), 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)

Example 39 with DecryptedMember

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

the class DecryptedGroupUtilTest method can_extract_uuid_from_bad_decrypted_member.

@Test
public void can_extract_uuid_from_bad_decrypted_member() {
    DecryptedMember decryptedMember = DecryptedMember.newBuilder().setUuid(ByteString.copyFrom(new byte[0])).build();
    UUID parsed = DecryptedGroupUtil.toUuid(decryptedMember);
    assertEquals(UuidUtil.UNKNOWN_UUID, parsed);
}
Also used : UUID(java.util.UUID) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) Test(org.junit.Test)

Example 40 with DecryptedMember

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

the class DecryptedGroupChangeActionsBuilderChangeSetModifier method moveAddToPromote.

@Override
public void moveAddToPromote(int i) {
    DecryptedMember addMemberAction = result.getNewMembersList().get(i);
    result.removeNewMembers(i);
    result.addPromotePendingMembers(addMemberAction);
}
Also used : 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