Remove dependency on presentations being present in AddMemberAction.

This commit is contained in:
Jordan Rose
2023-10-20 17:28:29 -07:00
committed by Cody Henthorne
parent 4f754ae309
commit 87bdebb21c
3 changed files with 12 additions and 9 deletions

View File

@@ -577,7 +577,7 @@ public final class GroupsV2Operations {
ACI aci;
ProfileKey profileKey;
if (modifyMemberProfileKeyAction.user_id.size() == 0 || modifyMemberProfileKeyAction.presentation.size() == 0) {
if (modifyMemberProfileKeyAction.user_id.size() == 0 || modifyMemberProfileKeyAction.profile_key.size() == 0) {
ProfileKeyCredentialPresentation presentation = new ProfileKeyCredentialPresentation(modifyMemberProfileKeyAction.presentation.toByteArray());
aci = decryptAci(ByteString.of(presentation.getUuidCiphertext().serialize()));
profileKey = decryptProfileKey(ByteString.of(presentation.getProfileKeyCiphertext().serialize()), aci);
@@ -1034,13 +1034,16 @@ public final class GroupsV2Operations {
));
}
public List<ServiceId> decryptAddMembers(List<GroupChange.Actions.AddMemberAction> addMembers) throws InvalidInputException, VerificationFailedException {
public List<ServiceId> decryptAddMembers(List<GroupChange.Actions.AddMemberAction> addMembers) throws InvalidGroupStateException, InvalidInputException, VerificationFailedException {
List<ServiceId> ids = new ArrayList<>(addMembers.size());
for (int i = 0; i < addMembers.size(); i++) {
GroupChange.Actions.AddMemberAction addMember = addMembers.get(i);
ProfileKeyCredentialPresentation profileKeyCredentialPresentation = new ProfileKeyCredentialPresentation(addMember.added.presentation.toByteArray());
for (GroupChange.Actions.AddMemberAction addMember : addMembers) {
if (addMember.added.presentation.size() == 0) {
ids.add(decryptAci(addMember.added.userId));
} else {
ProfileKeyCredentialPresentation profileKeyCredentialPresentation = new ProfileKeyCredentialPresentation(addMember.added.presentation.toByteArray());
ids.add(ServiceId.fromLibSignal(clientZkGroupCipher.decrypt(profileKeyCredentialPresentation.getUuidCiphertext())));
ids.add(ServiceId.fromLibSignal(clientZkGroupCipher.decrypt(profileKeyCredentialPresentation.getUuidCiphertext())));
}
}
return ids;
}