Page MenuHomePhabricator

D12315.id40974.diff
No OneTemporary

D12315.id40974.diff

diff --git a/lib/types/minimally-encoded-thread-permissions-types.js b/lib/types/minimally-encoded-thread-permissions-types.js
--- a/lib/types/minimally-encoded-thread-permissions-types.js
+++ b/lib/types/minimally-encoded-thread-permissions-types.js
@@ -105,6 +105,20 @@
+permissions: string,
}>;
+export type MemberInfoSansPermissions = {
+ +id: string,
+ +role: ?string,
+ +isSender: boolean,
+ +minimallyEncoded: true,
+};
+
+function stripPermissionsFromMemberInfo(
+ memberInfo: MemberInfoWithPermissions,
+): MemberInfoSansPermissions {
+ const { permissions, ...rest } = memberInfo;
+ return rest;
+}
+
const minimallyEncodeMemberInfo = (
memberInfo: LegacyMemberInfo,
): MemberInfoWithPermissions => {
@@ -219,6 +233,7 @@
decodeMinimallyEncodedRoleInfo,
minimallyEncodeThreadCurrentUserInfo,
decodeMinimallyEncodedThreadCurrentUserInfo,
+ stripPermissionsFromMemberInfo,
minimallyEncodeMemberInfo,
decodeMinimallyEncodedMemberInfo,
minimallyEncodeRawThreadInfo,
diff --git a/lib/types/minimally-encoded-thread-permissions-types.test.js b/lib/types/minimally-encoded-thread-permissions-types.test.js
new file mode 100644
--- /dev/null
+++ b/lib/types/minimally-encoded-thread-permissions-types.test.js
@@ -0,0 +1,29 @@
+// @flow
+
+import type {
+ MemberInfoSansPermissions,
+ MemberInfoWithPermissions,
+} from './minimally-encoded-thread-permissions-types.js';
+import { stripPermissionsFromMemberInfo } from './minimally-encoded-thread-permissions-types.js';
+
+describe('stripPermissionsFromMemberInfo', () => {
+ test('should produce valid MemberInfoSansPermissions', () => {
+ const memberInfoWithPermissions: MemberInfoWithPermissions = {
+ id: '1',
+ role: '2',
+ isSender: true,
+ minimallyEncoded: true,
+ permissions: '3',
+ };
+
+ const memberInfoSansPermissions: MemberInfoSansPermissions =
+ stripPermissionsFromMemberInfo(memberInfoWithPermissions);
+
+ expect(memberInfoSansPermissions).toEqual({
+ id: '1',
+ role: '2',
+ isSender: true,
+ minimallyEncoded: true,
+ });
+ });
+});

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 12:43 AM (22 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2509146
Default Alt Text
D12315.id40974.diff (2 KB)

Event Timeline