Always use server signed group change for updating local group

This commit is contained in:
AsamK 2026-10-14 11:57:50 +02:00
parent c3b0fe902e
commit c2b9c25b7c

View File

@ -636,32 +636,18 @@ class GroupV2Helper {
final DecryptedGroupChange decryptedChange;
final DecryptedGroup decryptedGroupState;
if (!changeActions.promote_members_pending_pni_aci_profile_key.isEmpty()) {
// The server fills in the ACI and PNI ciphertexts of a PNI promotion, so decrypt its signed change
final var signedGroupChange = dependencies.getGroupsV2Api()
.patchGroup(changeActions, getGroupAuthForToday(groupSecretParams), Optional.empty());
final var groupId = groupSecretParams.getPublicParams().getGroupIdentifier();
try {
decryptedChange = groupOperations.decryptChange(signedGroupChange.group_change,
DecryptChangeVerificationMode.verify(groupId)).orElseThrow();
decryptedGroupState = DecryptedGroupUtil.apply(previousGroupState, decryptedChange);
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
throw new IOException(e);
}
groupInfoV2.setGroup(decryptedGroupState);
return new Pair<>(decryptedGroupState, signedGroupChange);
}
var signedGroupChange = dependencies.getGroupsV2Api()
.patchGroup(changeActions, getGroupAuthForToday(groupSecretParams), Optional.empty());
final var groupId = groupSecretParams.getPublicParams().getGroupIdentifier();
try {
decryptedChange = groupOperations.decryptChange(changeActions, getSelfAci());
decryptedChange = groupOperations.decryptChange(signedGroupChange.group_change,
DecryptChangeVerificationMode.verify(groupId)).orElseThrow();
decryptedGroupState = DecryptedGroupUtil.apply(previousGroupState, decryptedChange);
} catch (VerificationFailedException | InvalidGroupStateException | NotAbleToApplyGroupV2ChangeException e) {
throw new IOException(e);
}
var signedGroupChange = dependencies.getGroupsV2Api()
.patchGroup(changeActions, getGroupAuthForToday(groupSecretParams), Optional.empty());
groupInfoV2.setGroup(decryptedGroupState);
return new Pair<>(decryptedGroupState, signedGroupChange);