Skip to content

Commit

Permalink
Fix group state decoding for default values
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-signal committed Nov 13, 2023
1 parent f8b936f commit 046a3c4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ts/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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) {
Expand Down

0 comments on commit 046a3c4

Please sign in to comment.