Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3156407
D10791.id36086.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D10791.id36086.diff
View Options
diff --git a/lib/permissions/minimally-encoded-thread-permissions-validators.js b/lib/permissions/minimally-encoded-thread-permissions-validators.js
--- a/lib/permissions/minimally-encoded-thread-permissions-validators.js
+++ b/lib/permissions/minimally-encoded-thread-permissions-validators.js
@@ -8,7 +8,7 @@
} from './minimally-encoded-thread-permissions.js';
import { clientAvatarValidator } from '../types/avatar-types.js';
import type {
- MinimallyEncodedMemberInfo,
+ MemberInfo,
MinimallyEncodedThreadCurrentUserInfo,
RawThreadInfo,
RelativeMemberInfo,
@@ -40,16 +40,15 @@
permissions: tHexEncodedPermissionsBitmask,
});
-const minimallyEncodedMemberInfoValidator: TInterface<MinimallyEncodedMemberInfo> =
- tShape<MinimallyEncodedMemberInfo>({
- ...legacyMemberInfoValidator.meta.props,
- minimallyEncoded: tBool(true),
- permissions: tHexEncodedPermissionsBitmask,
- });
+const MemberInfoValidator: TInterface<MemberInfo> = tShape<MemberInfo>({
+ ...legacyMemberInfoValidator.meta.props,
+ minimallyEncoded: tBool(true),
+ permissions: tHexEncodedPermissionsBitmask,
+});
const minimallyEncodedRelativeMemberInfoValidator: TInterface<RelativeMemberInfo> =
tShape<RelativeMemberInfo>({
- ...minimallyEncodedMemberInfoValidator.meta.props,
+ ...MemberInfoValidator.meta.props,
username: t.maybe(t.String),
isViewer: t.Boolean,
});
@@ -80,7 +79,7 @@
tShape<RawThreadInfo>({
...legacyRawThreadInfoValidator.meta.props,
minimallyEncoded: tBool(true),
- members: t.list(minimallyEncodedMemberInfoValidator),
+ members: t.list(MemberInfoValidator),
roles: t.dict(tID, minimallyEncodedRoleInfoValidator),
currentUser: minimallyEncodedThreadCurrentUserInfoValidator,
});
@@ -95,7 +94,7 @@
export {
minimallyEncodedRoleInfoValidator,
minimallyEncodedThreadCurrentUserInfoValidator,
- minimallyEncodedMemberInfoValidator,
+ MemberInfoValidator,
minimallyEncodedRelativeMemberInfoValidator,
minimallyEncodedThreadInfoValidator,
minimallyEncodedRawThreadInfoValidator,
diff --git a/lib/permissions/minimally-encoded-thread-permissions.test.js b/lib/permissions/minimally-encoded-thread-permissions.test.js
--- a/lib/permissions/minimally-encoded-thread-permissions.test.js
+++ b/lib/permissions/minimally-encoded-thread-permissions.test.js
@@ -6,7 +6,7 @@
expectedDecodedExampleRawThreadInfoA,
} from './minimally-encoded-thread-permissions-test-data.js';
import {
- minimallyEncodedMemberInfoValidator,
+ MemberInfoValidator,
minimallyEncodedRawThreadInfoValidator,
minimallyEncodedRoleInfoValidator,
minimallyEncodedThreadCurrentUserInfoValidator,
@@ -446,7 +446,7 @@
describe('minimallyEncodedMemberInfoValidator', () => {
it('should validate correctly formed MinimallyEncodedMemberInfo', () => {
expect(
- minimallyEncodedMemberInfoValidator.is({
+ MemberInfoValidator.is({
minimallyEncoded: true,
id: 'memberID',
permissions: 'ABCDEF',
@@ -455,7 +455,7 @@
).toBe(true);
expect(
- minimallyEncodedMemberInfoValidator.is({
+ MemberInfoValidator.is({
minimallyEncoded: true,
id: 'memberID',
permissions: '01b',
@@ -466,7 +466,7 @@
it('should NOT validate malformed MinimallyEncodedMemberInfo', () => {
expect(
- minimallyEncodedMemberInfoValidator.is({
+ MemberInfoValidator.is({
minimallyEncoded: true,
id: 'memberID',
permissions: 'INVALID',
@@ -475,7 +475,7 @@
).toBe(false);
expect(
- minimallyEncodedMemberInfoValidator.is({
+ MemberInfoValidator.is({
minimallyEncoded: true,
id: 'memberID',
permissions: 100,
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -58,8 +58,9 @@
type ComposableMessageInfo,
} from '../types/message-types.js';
import type {
- RawThreadInfo,
+ MemberInfo,
MinimallyEncodedThreadCurrentUserInfo,
+ RawThreadInfo,
RelativeMemberInfo,
RoleInfo,
ThreadInfo,
@@ -218,7 +219,7 @@
}
function threadActualMembers(
- memberInfos: $ReadOnlyArray<MinimallyEncodedMemberInfo | RelativeMemberInfo>,
+ memberInfos: $ReadOnlyArray<MemberInfo | RelativeMemberInfo>,
): $ReadOnlyArray<string> {
return memberInfos
.filter(memberInfo => memberInfo.role)
@@ -226,7 +227,7 @@
}
function threadOtherMembers<
- T: LegacyMemberInfo | MinimallyEncodedMemberInfo | RelativeMemberInfo,
+ T: LegacyMemberInfo | MemberInfo | RelativeMemberInfo,
>(memberInfos: $ReadOnlyArray<T>, viewerID: ?string): $ReadOnlyArray<T> {
return memberInfos.filter(
memberInfo => memberInfo.role && memberInfo.id !== viewerID,
@@ -1031,7 +1032,7 @@
memberInfo:
| RelativeMemberInfo
| LegacyMemberInfo
- | MinimallyEncodedMemberInfo
+ | MemberInfo
| ServerMemberInfo,
): boolean {
if (memberInfo.minimallyEncoded) {
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
@@ -81,7 +81,7 @@
};
};
-export type MinimallyEncodedMemberInfo = $ReadOnly<{
+export type MemberInfo = $ReadOnly<{
...LegacyMemberInfo,
+minimallyEncoded: true,
+permissions: string,
@@ -89,7 +89,7 @@
const minimallyEncodeMemberInfo = (
memberInfo: LegacyMemberInfo,
-): MinimallyEncodedMemberInfo => {
+): MemberInfo => {
invariant(
!('minimallyEncoded' in memberInfo),
'memberInfo is already minimally encoded.',
@@ -102,7 +102,7 @@
};
const decodeMinimallyEncodedMemberInfo = (
- minimallyEncodedMemberInfo: MinimallyEncodedMemberInfo,
+ minimallyEncodedMemberInfo: MemberInfo,
): LegacyMemberInfo => {
const { minimallyEncoded, ...rest } = minimallyEncodedMemberInfo;
return {
@@ -114,7 +114,7 @@
};
export type RelativeMemberInfo = $ReadOnly<{
- ...MinimallyEncodedMemberInfo,
+ ...MemberInfo,
+username: ?string,
+isViewer: boolean,
}>;
@@ -122,7 +122,7 @@
export type RawThreadInfo = $ReadOnly<{
...LegacyRawThreadInfo,
+minimallyEncoded: true,
- +members: $ReadOnlyArray<MinimallyEncodedMemberInfo>,
+ +members: $ReadOnlyArray<MemberInfo>,
+roles: { +[id: string]: RoleInfo },
+currentUser: MinimallyEncodedThreadCurrentUserInfo,
}>;
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
@@ -3,12 +3,12 @@
import invariant from 'invariant';
import {
- minimallyEncodedMemberInfoValidator,
+ MemberInfoValidator,
minimallyEncodedRoleInfoValidator,
minimallyEncodedThreadCurrentUserInfoValidator,
} from '../permissions/minimally-encoded-thread-permissions-validators.js';
import type {
- MinimallyEncodedMemberInfo,
+ MemberInfo,
RawThreadInfo,
RoleInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
@@ -46,17 +46,18 @@
): RawThreadInfo {
// 1. Validate and potentially minimally encode `rawMembers`.
const rawMembers = JSON.parse(clientDBThreadInfo.members);
- const minimallyEncodedMembers: $ReadOnlyArray<MinimallyEncodedMemberInfo> =
- rawMembers.map(rawMember => {
+ const minimallyEncodedMembers: $ReadOnlyArray<MemberInfo> = rawMembers.map(
+ rawMember => {
invariant(
- minimallyEncodedMemberInfoValidator.is(rawMember) ||
+ MemberInfoValidator.is(rawMember) ||
legacyMemberInfoValidator.is(rawMember),
'rawMember must be valid [MinimallyEncoded/Legacy]MemberInfo',
);
return rawMember.minimallyEncoded
? rawMember
: minimallyEncodeMemberInfo(rawMember);
- });
+ },
+ );
// 2. Validate and potentially minimally encode `rawRoles`.
const rawRoles = JSON.parse(clientDBThreadInfo.roles);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 6, 3:27 PM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2431282
Default Alt Text
D10791.id36086.diff (7 KB)
Attached To
Mode
D10791: [lib] Rename `MinimallyEncodedMemberInfo` to `MemberInfo`
Attached
Detach File
Event Timeline
Log In to Comment