Page MenuHomePhabricator

D12758.id42301.diff
No OneTemporary

D12758.id42301.diff

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
@@ -15,6 +15,7 @@
RoleInfoWithoutSpecialRole,
RawThreadInfoWithoutSpecialRole,
MinimallyEncodedThickMemberInfo,
+ MemberInfoSansPermissions,
} from '../types/minimally-encoded-thread-permissions-types.js';
import { threadSubscriptionValidator } from '../types/subscription-types.js';
import {
@@ -71,6 +72,14 @@
permissions: tHexEncodedPermissionsBitmask,
});
+const memberInfoSansPermissionsValidator: TInterface<MemberInfoSansPermissions> =
+ tShape<MemberInfoSansPermissions>({
+ id: tUserID,
+ role: t.maybe(tID),
+ isSender: t.Boolean,
+ minimallyEncoded: tBool(true),
+ });
+
const minimallyEncodedThickMemberInfoValidator: TInterface<MinimallyEncodedThickMemberInfo> =
tShape<MinimallyEncodedThickMemberInfo>({
minimallyEncoded: tBool(true),
@@ -85,7 +94,10 @@
{
...legacyRawThreadInfoValidator.meta.props,
minimallyEncoded: tBool(true),
- members: t.list(memberInfoWithPermissionsValidator),
+ members: t.union([
+ t.list(memberInfoWithPermissionsValidator),
+ t.list(memberInfoSansPermissionsValidator),
+ ]),
roles: t.dict(tID, roleInfoValidator),
currentUser: threadCurrentUserInfoValidator,
},
@@ -113,6 +125,7 @@
export {
memberInfoWithPermissionsValidator,
+ memberInfoSansPermissionsValidator,
minimallyEncodedThickMemberInfoValidator,
roleInfoValidator,
persistedRoleInfoValidator,
diff --git a/lib/permissions/minimally-encoded-raw-thread-info-validators.test.js b/lib/permissions/minimally-encoded-raw-thread-info-validators.test.js
new file mode 100644
--- /dev/null
+++ b/lib/permissions/minimally-encoded-raw-thread-info-validators.test.js
@@ -0,0 +1,30 @@
+// @flow
+
+import { memberInfoSansPermissionsValidator } from './minimally-encoded-raw-thread-info-validators.js';
+
+describe('memberInfoSansPermissionsValidator should validate correctly formed MemberInfoSansPermissions', () => {
+ test('should validate correctly formed MemberInfoSansPermissions', () => {
+ const memberInfoSansPermissions = {
+ id: '1',
+ role: '2',
+ isSender: true,
+ minimallyEncoded: true,
+ };
+
+ expect(
+ memberInfoSansPermissionsValidator.is(memberInfoSansPermissions),
+ ).toBe(true);
+ });
+
+ test('should NOT validate MemberInfoSansPermissions without id', () => {
+ const memberInfoSansPermissions = {
+ role: '2',
+ isSender: true,
+ minimallyEncoded: true,
+ };
+
+ expect(
+ memberInfoSansPermissionsValidator.is(memberInfoSansPermissions),
+ ).toBe(false);
+ });
+});

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 6:10 AM (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2449533
Default Alt Text
D12758.id42301.diff (2 KB)

Event Timeline