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)));
}
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);
}
}
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));
}
}
}
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;
}
Aggregations