use of org.signal.storageservice.protos.groups.local.DecryptedPendingMember in project Signal-Android by signalapp.
the class GroupsV2UpdateMessageProducer method describeNewGroup.
/**
* Describes a group that is new to you, use this when there is no available change record.
* <p>
* Invitation and revision 0 groups are the most common use cases for this.
* <p>
* When invited, it's possible there's no change available.
* <p>
* When the revision of the group is 0, the change is very noisy and only the editor is useful.
*/
UpdateDescription describeNewGroup(@NonNull DecryptedGroup group, @NonNull DecryptedGroupChange decryptedGroupChange) {
Optional<DecryptedPendingMember> selfPending = DecryptedGroupUtil.findPendingByUuid(group.getPendingMembersList(), selfUuid);
if (selfPending.isPresent()) {
return updateDescription(selfPending.get().getAddedByUuid(), inviteBy -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, inviteBy), R.drawable.ic_update_group_add_16);
}
ByteString foundingMemberUuid = decryptedGroupChange.getEditor();
if (!foundingMemberUuid.isEmpty()) {
if (selfUuidBytes.equals(foundingMemberUuid)) {
return updateDescription(context.getString(R.string.MessageRecord_you_created_the_group), R.drawable.ic_update_group_16);
} else {
return updateDescription(foundingMemberUuid, creator -> context.getString(R.string.MessageRecord_s_added_you, creator), R.drawable.ic_update_group_add_16);
}
}
if (DecryptedGroupUtil.findMemberByUuid(group.getMembersList(), selfUuid).isPresent()) {
return updateDescription(context.getString(R.string.MessageRecord_you_joined_the_group), R.drawable.ic_update_group_add_16);
} else {
return updateDescription(context.getString(R.string.MessageRecord_group_updated), R.drawable.ic_update_group_16);
}
}
use of org.signal.storageservice.protos.groups.local.DecryptedPendingMember in project Signal-Android by signalapp.
the class GroupsV2UpdateMessageProducer method describeInvitations.
private void describeInvitations(@NonNull DecryptedGroupChange change, @NonNull List<UpdateDescription> updates) {
boolean editorIsYou = change.getEditor().equals(selfUuidBytes);
int notYouInviteCount = 0;
for (DecryptedPendingMember invitee : change.getNewPendingMembersList()) {
boolean newMemberIsYou = invitee.getUuid().equals(selfUuidBytes);
if (newMemberIsYou) {
updates.add(0, updateDescription(change.getEditor(), editor -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, editor), R.drawable.ic_update_group_add_16));
} else {
if (editorIsYou) {
updates.add(updateDescription(invitee.getUuid(), newInvitee -> context.getString(R.string.MessageRecord_you_invited_s_to_the_group, newInvitee), R.drawable.ic_update_group_add_16));
} else {
notYouInviteCount++;
}
}
}
if (notYouInviteCount > 0) {
final int notYouInviteCountFinalCopy = notYouInviteCount;
updates.add(updateDescription(change.getEditor(), editor -> context.getResources().getQuantityString(R.plurals.MessageRecord_s_invited_members, notYouInviteCountFinalCopy, editor, notYouInviteCountFinalCopy), R.drawable.ic_update_group_add_16));
}
}
use of org.signal.storageservice.protos.groups.local.DecryptedPendingMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method remove_pending_member.
@Test
public void remove_pending_member() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
UUID pendingUuid = UUID.randomUUID();
DecryptedPendingMember pending = pendingMember(pendingUuid);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addDeletePendingMembers(DecryptedPendingMemberRemoval.newBuilder().setUuidCipherText(ProtoTestUtils.encrypt(pendingUuid)).build()).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedPendingMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method promote_pending_member.
@Test
public void promote_pending_member() throws NotAbleToApplyGroupV2ChangeException {
ProfileKey profileKey2 = randomProfileKey();
DecryptedMember member1 = member(UUID.randomUUID());
UUID pending2Uuid = UUID.randomUUID();
DecryptedPendingMember pending2 = pendingMember(pending2Uuid);
DecryptedMember member2 = member(pending2Uuid, profileKey2);
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending2).build(), DecryptedGroupChange.newBuilder().setRevision(11).addPromotePendingMembers(member2).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).build(), newGroup);
}
use of org.signal.storageservice.protos.groups.local.DecryptedPendingMember in project Signal-Android by signalapp.
the class DecryptedGroupUtil_apply_Test method apply_new_pending_member_already_pending.
@Test
public void apply_new_pending_member_already_pending() throws NotAbleToApplyGroupV2ChangeException {
DecryptedMember member1 = member(UUID.randomUUID());
DecryptedPendingMember pending = pendingMember(UUID.randomUUID());
DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addPendingMembers(pending).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewPendingMembers(pending).build());
assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addPendingMembers(pending).build(), newGroup);
}
Aggregations