Fix group state decoding for default values

This commit is contained in:
trevor-signal 2023-11-13 13:55:14 -05:00 committed by GitHub
parent f8b936f258
commit 046a3c4849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6603,9 +6603,13 @@ function decryptGroupState(
const { accessControl } = groupState;
strictAssert(accessControl, 'No accessControl field found');
const attributes = dropNull(accessControl.attributes);
const members = dropNull(accessControl.members);
const addFromInviteLink = dropNull(accessControl.addFromInviteLink);
const attributes =
accessControl.attributes ?? Proto.AccessControl.AccessRequired.UNKNOWN;
const members =
accessControl.members ?? Proto.AccessControl.AccessRequired.UNKNOWN;
const addFromInviteLink =
accessControl.addFromInviteLink ??
Proto.AccessControl.AccessRequired.UNKNOWN;
strictAssert(
isValidAccess(attributes),
@ -6628,11 +6632,12 @@ function decryptGroupState(
}
// version
const version = groupState.version ?? 0;
strictAssert(
isNumber(groupState.version),
`decryptGroupState: Expected version to be a number; it was ${groupState.version}`
isNumber(version),
`decryptGroupState: Expected version to be a number or null; it was ${groupState.version}`
);
result.version = groupState.version;
result.version = version;
// members
if (groupState.members) {