Search in sources :

Example 1 with DecryptedPendingMemberRemoval

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

the class DecryptedGroupUtilTest method can_extract_uuids_for_all_deleted_pending_excluding_bad_entries.

@Test
public void can_extract_uuids_for_all_deleted_pending_excluding_bad_entries() {
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    DecryptedPendingMemberRemoval decryptedMember1 = DecryptedPendingMemberRemoval.newBuilder().setUuid(UuidUtil.toByteString(uuid1)).build();
    DecryptedPendingMemberRemoval decryptedMember2 = DecryptedPendingMemberRemoval.newBuilder().setUuid(UuidUtil.toByteString(uuid2)).build();
    DecryptedPendingMemberRemoval decryptedMember3 = DecryptedPendingMemberRemoval.newBuilder().setUuid(ByteString.copyFrom(Util.getSecretBytes(17))).build();
    DecryptedGroupChange groupChange = DecryptedGroupChange.newBuilder().addDeletePendingMembers(decryptedMember1).addDeletePendingMembers(decryptedMember2).addDeletePendingMembers(decryptedMember3).build();
    List<UUID> removedUuids = DecryptedGroupUtil.removedPendingMembersUuidList(groupChange);
    assertThat(removedUuids, is(asList(uuid1, uuid2)));
}
Also used : DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with DecryptedPendingMemberRemoval

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

the class DecryptedGroupUtil method applyDeletePendingMemberActions.

protected static void applyDeletePendingMemberActions(DecryptedGroup.Builder builder, List<DecryptedPendingMemberRemoval> deletePendingMembersList) {
    for (DecryptedPendingMemberRemoval removedMember : deletePendingMembersList) {
        int index = findPendingIndexByUuidCipherText(builder.getPendingMembersList(), removedMember.getUuidCipherText());
        if (index == -1) {
            Log.w(TAG, "Deleted pending member on change not found in group");
            continue;
        }
        builder.removePendingMembers(index);
    }
}
Also used : DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval)

Example 3 with DecryptedPendingMemberRemoval

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

the class GroupsV2UpdateMessageProducer method describeRevokedInvitations.

private void describeRevokedInvitations(@NonNull DecryptedGroupChange change, @NonNull List<UpdateDescription> updates) {
    boolean editorIsYou = change.getEditor().equals(selfUuidBytes);
    int notDeclineCount = 0;
    for (DecryptedPendingMemberRemoval invitee : change.getDeletePendingMembersList()) {
        boolean decline = invitee.getUuid().equals(change.getEditor());
        if (decline) {
            if (editorIsYou) {
                updates.add(updateDescription(context.getString(R.string.MessageRecord_you_declined_the_invitation_to_the_group), R.drawable.ic_update_group_decline_16));
            } else {
                updates.add(updateDescription(context.getString(R.string.MessageRecord_someone_declined_an_invitation_to_the_group), R.drawable.ic_update_group_decline_16));
            }
        } else if (invitee.getUuid().equals(selfUuidBytes)) {
            updates.add(updateDescription(change.getEditor(), editor -> context.getString(R.string.MessageRecord_s_revoked_your_invitation_to_the_group, editor), R.drawable.ic_update_group_decline_16));
        } else {
            notDeclineCount++;
        }
    }
    if (notDeclineCount > 0) {
        if (editorIsYou) {
            updates.add(updateDescription(context.getResources().getQuantityString(R.plurals.MessageRecord_you_revoked_invites, notDeclineCount, notDeclineCount), R.drawable.ic_update_group_decline_16));
        } else {
            final int notDeclineCountFinalCopy = notDeclineCount;
            updates.add(updateDescription(change.getEditor(), editor -> context.getResources().getQuantityString(R.plurals.MessageRecord_s_revoked_invites, notDeclineCountFinalCopy, editor, notDeclineCountFinalCopy), R.drawable.ic_update_group_decline_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) DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval)

Example 4 with DecryptedPendingMemberRemoval

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

the class DecryptedGroupUtil method removedPendingMembersUuidList.

/**
 * Will not return any non-decryptable member UUIDs.
 */
public static ArrayList<UUID> removedPendingMembersUuidList(DecryptedGroupChange groupChange) {
    List<DecryptedPendingMemberRemoval> deletedPendingMembers = groupChange.getDeletePendingMembersList();
    ArrayList<UUID> uuidList = new ArrayList<>(deletedPendingMembers.size());
    for (DecryptedPendingMemberRemoval member : deletedPendingMembers) {
        UUID uuid = toUuid(member.getUuid());
        if (!UuidUtil.UNKNOWN_UUID.equals(uuid)) {
            uuidList.add(uuid);
        }
    }
    return uuidList;
}
Also used : ArrayList(java.util.ArrayList) DecryptedPendingMemberRemoval(org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval) UUID(java.util.UUID)

Aggregations

DecryptedPendingMemberRemoval (org.signal.storageservice.protos.groups.local.DecryptedPendingMemberRemoval)4 UUID (java.util.UUID)3 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)2 Context (android.content.Context)1 DrawableRes (androidx.annotation.DrawableRes)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 WorkerThread (androidx.annotation.WorkerThread)1 ByteString (com.google.protobuf.ByteString)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Test (org.junit.Test)1 AccessControl (org.signal.storageservice.protos.groups.AccessControl)1 Member (org.signal.storageservice.protos.groups.Member)1 DecryptedApproveMember (org.signal.storageservice.protos.groups.local.DecryptedApproveMember)1 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)1 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)1