Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3181347
D12758.id42301.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12758.id42301.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D12758: [lib] Introduce `memberInfoSansPermissionsValidator` and consume in `rawThreadInfoValidator`
Attached
Detach File
Event Timeline
Log In to Comment