diff --git a/lib/permissions/minimally-encoded-raw-thread-info-validators.js b/lib/permissions/minimally-encoded-raw-thread-info-validators.js --- a/lib/permissions/minimally-encoded-raw-thread-info-validators.js +++ b/lib/permissions/minimally-encoded-raw-thread-info-validators.js @@ -14,14 +14,16 @@ RoleInfo, RoleInfoWithoutSpecialRole, RawThreadInfoWithoutSpecialRole, + MinimallyEncodedThickMemberInfo, } from '../types/minimally-encoded-thread-permissions-types.js'; +import { threadSubscriptionValidator } from '../types/subscription-types.js'; import { type LegacyRawThreadInfo, legacyMemberInfoValidator, legacyRawThreadInfoValidator, legacyThreadCurrentUserInfoValidator, } from '../types/thread-types.js'; -import { tBool, tID, tShape } from '../utils/validation-utils.js'; +import { tBool, tID, tShape, tUserID } from '../utils/validation-utils.js'; const threadCurrentUserInfoValidator: TInterface = tShape({ @@ -69,6 +71,16 @@ permissions: tHexEncodedPermissionsBitmask, }); +const minimallyEncodedThickMemberInfoValidator: TInterface = + tShape({ + minimallyEncoded: tBool(true), + id: tUserID, + role: t.maybe(tID), + permissions: tHexEncodedPermissionsBitmask, + isSender: t.Boolean, + subscription: threadSubscriptionValidator, + }); + const rawThreadInfoValidator: TInterface = tShape( { ...legacyRawThreadInfoValidator.meta.props, @@ -101,6 +113,7 @@ export { memberInfoWithPermissionsValidator, + minimallyEncodedThickMemberInfoValidator, roleInfoValidator, persistedRoleInfoValidator, threadCurrentUserInfoValidator, diff --git a/lib/utils/thread-ops-utils.js b/lib/utils/thread-ops-utils.js --- a/lib/utils/thread-ops-utils.js +++ b/lib/utils/thread-ops-utils.js @@ -6,6 +6,7 @@ memberInfoWithPermissionsValidator, persistedRoleInfoValidator, threadCurrentUserInfoValidator, + minimallyEncodedThickMemberInfoValidator, } from '../permissions/minimally-encoded-raw-thread-info-validators.js'; import type { RawThreadInfo, @@ -52,10 +53,9 @@ const rawMembers = JSON.parse(clientDBThreadInfo.members); const minimallyEncodedMembers = rawMembers.map(rawMember => { invariant( - // TODO these must be updated to accept new client-only change - // that subscription field may be present memberInfoWithPermissionsValidator.is(rawMember) || - legacyMemberInfoValidator.is(rawMember), + legacyMemberInfoValidator.is(rawMember) || + minimallyEncodedThickMemberInfoValidator.is(rawMember), 'rawMember must be valid [MinimallyEncoded/Legacy]MemberInfo', ); return rawMember.minimallyEncoded