Page MenuHomePhabricator

D10806.diff
No OneTemporary

D10806.diff

diff --git a/keyserver/src/responders/redux-state-responders.js b/keyserver/src/responders/redux-state-responders.js
--- a/keyserver/src/responders/redux-state-responders.js
+++ b/keyserver/src/responders/redux-state-responders.js
@@ -4,7 +4,7 @@
import t, { type TInterface } from 'tcomb';
import { baseLegalPolicies } from 'lib/facts/policies.js';
-import { rawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
import { daysToEntriesFromEntryInfos } from 'lib/reducers/entry-reducer.js';
import { freshMessageStore } from 'lib/reducers/message-reducer.js';
import { mostRecentlyReadThread } from 'lib/selectors/thread-selectors.js';
@@ -81,7 +81,7 @@
export const threadStoreValidator: TInterface<ThreadStore> =
tShape<ThreadStore>({
- threadInfos: t.dict(tID, rawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
});
export const initialReduxStateValidator: TInterface<InitialReduxStateResponse> =
diff --git a/keyserver/src/responders/thread-responders.js b/keyserver/src/responders/thread-responders.js
--- a/keyserver/src/responders/thread-responders.js
+++ b/keyserver/src/responders/thread-responders.js
@@ -3,7 +3,7 @@
import t from 'tcomb';
import type { TInterface, TUnion } from 'tcomb';
-import { rawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
import { mediaValidator } from 'lib/types/media-types.js';
import {
rawMessageInfoValidator,
@@ -289,7 +289,7 @@
export const roleModificationResultValidator: TInterface<RoleModificationResult> =
tShape<RoleModificationResult>({
- threadInfo: t.maybe(rawThreadInfoValidator),
+ threadInfo: t.maybe(mixedRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
@@ -310,7 +310,7 @@
export const roleDeletionResultValidator: TInterface<RoleDeletionResult> =
tShape<RoleDeletionResult>({
- threadInfo: t.maybe(rawThreadInfoValidator),
+ threadInfo: t.maybe(mixedRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js
--- a/keyserver/src/responders/user-responders.js
+++ b/keyserver/src/responders/user-responders.js
@@ -12,7 +12,7 @@
policies,
policyTypeValidator,
} from 'lib/facts/policies.js';
-import { rawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
import { hasMinCodeVersion } from 'lib/shared/version-utils.js';
import type {
KeyserverAuthRequest,
@@ -261,7 +261,7 @@
rawMessageInfos: t.list(rawMessageInfoValidator),
currentUserInfo: loggedInUserInfoValidator,
cookieChange: tShape({
- threadInfos: t.dict(tID, rawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
});
@@ -470,7 +470,7 @@
rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)),
serverTime: t.Number,
cookieChange: tShape({
- threadInfos: t.dict(tID, rawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
notAcknowledgedPolicies: t.maybe(t.list<TEnums>(policyTypeValidator)),
diff --git a/keyserver/src/shared/state-sync/threads-state-sync-spec.js b/keyserver/src/shared/state-sync/threads-state-sync-spec.js
--- a/keyserver/src/shared/state-sync/threads-state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/threads-state-sync-spec.js
@@ -1,6 +1,6 @@
// @flow
-import { rawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
import { threadsStateSyncSpec as libSpec } from 'lib/shared/state-sync/threads-state-sync-spec.js';
import type { RawThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { ClientThreadInconsistencyReportCreationRequest } from 'lib/types/report-types.js';
@@ -46,5 +46,5 @@
}
function getServerInfoHash(info: LegacyRawThreadInfo | RawThreadInfo) {
- return hash(validateOutput(null, rawThreadInfoValidator, info));
+ return hash(validateOutput(null, mixedRawThreadInfoValidator, info));
}
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
@@ -26,12 +26,11 @@
import { threadEntityValidator } from '../utils/entity-text.js';
import { tBool, tID, tShape } from '../utils/validation-utils.js';
-const minimallyEncodedRoleInfoValidator: TInterface<RoleInfo> =
- tShape<RoleInfo>({
- ...legacyRoleInfoValidator.meta.props,
- minimallyEncoded: tBool(true),
- permissions: t.list(tHexEncodedRolePermission),
- });
+const roleInfoValidator: TInterface<RoleInfo> = tShape<RoleInfo>({
+ ...legacyRoleInfoValidator.meta.props,
+ minimallyEncoded: tBool(true),
+ permissions: t.list(tHexEncodedRolePermission),
+});
const threadCurrentUserInfoValidator: TInterface<ThreadCurrentUserInfo> =
tShape<ThreadCurrentUserInfo>({
@@ -46,56 +45,53 @@
permissions: tHexEncodedPermissionsBitmask,
});
-const minimallyEncodedRelativeMemberInfoValidator: TInterface<RelativeMemberInfo> =
+const relativeMemberInfoValidator: TInterface<RelativeMemberInfo> =
tShape<RelativeMemberInfo>({
...MemberInfoValidator.meta.props,
username: t.maybe(t.String),
isViewer: t.Boolean,
});
-const minimallyEncodedThreadInfoValidator: TInterface<ThreadInfo> =
- tShape<ThreadInfo>({
- minimallyEncoded: tBool(true),
- id: tID,
- type: threadTypeValidator,
- name: t.maybe(t.String),
- uiName: t.union([t.String, threadEntityValidator]),
- avatar: t.maybe(clientAvatarValidator),
- description: t.maybe(t.String),
- color: t.String,
- creationTime: t.Number,
- parentThreadID: t.maybe(tID),
- containingThreadID: t.maybe(tID),
- community: t.maybe(tID),
- members: t.list(minimallyEncodedRelativeMemberInfoValidator),
- roles: t.dict(tID, minimallyEncodedRoleInfoValidator),
- currentUser: threadCurrentUserInfoValidator,
- sourceMessageID: t.maybe(tID),
- repliesCount: t.Number,
- pinnedCount: t.maybe(t.Number),
- });
+const threadInfoValidator: TInterface<ThreadInfo> = tShape<ThreadInfo>({
+ minimallyEncoded: tBool(true),
+ id: tID,
+ type: threadTypeValidator,
+ name: t.maybe(t.String),
+ uiName: t.union([t.String, threadEntityValidator]),
+ avatar: t.maybe(clientAvatarValidator),
+ description: t.maybe(t.String),
+ color: t.String,
+ creationTime: t.Number,
+ parentThreadID: t.maybe(tID),
+ containingThreadID: t.maybe(tID),
+ community: t.maybe(tID),
+ members: t.list(relativeMemberInfoValidator),
+ roles: t.dict(tID, roleInfoValidator),
+ currentUser: threadCurrentUserInfoValidator,
+ sourceMessageID: t.maybe(tID),
+ repliesCount: t.Number,
+ pinnedCount: t.maybe(t.Number),
+});
-const minimallyEncodedRawThreadInfoValidator: TInterface<RawThreadInfo> =
- tShape<RawThreadInfo>({
+const rawThreadInfoValidator: TInterface<RawThreadInfo> = tShape<RawThreadInfo>(
+ {
...legacyRawThreadInfoValidator.meta.props,
minimallyEncoded: tBool(true),
members: t.list(MemberInfoValidator),
- roles: t.dict(tID, minimallyEncodedRoleInfoValidator),
+ roles: t.dict(tID, roleInfoValidator),
currentUser: threadCurrentUserInfoValidator,
- });
+ },
+);
-export const rawThreadInfoValidator: TUnion<
+export const mixedRawThreadInfoValidator: TUnion<
LegacyRawThreadInfo | RawThreadInfo,
-> = t.union([
- legacyRawThreadInfoValidator,
- minimallyEncodedRawThreadInfoValidator,
-]);
+> = t.union([legacyRawThreadInfoValidator, rawThreadInfoValidator]);
export {
- minimallyEncodedRoleInfoValidator,
+ roleInfoValidator,
threadCurrentUserInfoValidator,
MemberInfoValidator,
- minimallyEncodedRelativeMemberInfoValidator,
- minimallyEncodedThreadInfoValidator,
- minimallyEncodedRawThreadInfoValidator,
+ relativeMemberInfoValidator,
+ threadInfoValidator,
+ rawThreadInfoValidator,
};
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
@@ -7,8 +7,8 @@
} from './minimally-encoded-thread-permissions-test-data.js';
import {
MemberInfoValidator,
- minimallyEncodedRawThreadInfoValidator,
- minimallyEncodedRoleInfoValidator,
+ rawThreadInfoValidator,
+ roleInfoValidator,
threadCurrentUserInfoValidator,
} from './minimally-encoded-thread-permissions-validators.js';
import {
@@ -340,7 +340,7 @@
describe('minimallyEncodedRoleInfoValidator', () => {
it('should validate correctly formed MinimallyEncodedRoleInfo', () => {
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
minimallyEncoded: true,
id: 'roleID',
name: 'roleName',
@@ -352,7 +352,7 @@
it('should NOT validate malformed MinimallyEncodedRoleInfo', () => {
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
id: 1234,
name: 'roleName',
permissions: ['abc', 'def'],
@@ -361,7 +361,7 @@
).toBe(false);
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
id: 'roleID',
name: 'roleName',
permissions: ['hello a02 test', 'def'],
@@ -370,7 +370,7 @@
).toBe(false);
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
id: 'roleID',
name: 'roleName',
permissions: [123, 456],
@@ -379,7 +379,7 @@
).toBe(false);
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
id: 'roleID',
name: 'roleName',
permissions: ['ZZZ', 'YYY'],
@@ -388,7 +388,7 @@
).toBe(false);
expect(
- minimallyEncodedRoleInfoValidator.is({
+ roleInfoValidator.is({
id: 'roleID',
name: 'roleName',
permissions: ['AAAAA', 'YYY'],
@@ -488,9 +488,7 @@
describe('minimallyEncodedRawThreadInfoValidator', () => {
it('should validate correctly formed MinimallyEncodedRawThreadInfo', () => {
expect(
- minimallyEncodedRawThreadInfoValidator.is(
- exampleMinimallyEncodedRawThreadInfoA,
- ),
+ rawThreadInfoValidator.is(exampleMinimallyEncodedRawThreadInfoA),
).toBe(true);
});
});
@@ -498,7 +496,7 @@
describe('minimallyEncodeRawThreadInfo', () => {
it('should correctly encode RawThreadInfo', () => {
expect(
- minimallyEncodedRawThreadInfoValidator.is(
+ rawThreadInfoValidator.is(
minimallyEncodeRawThreadInfo(exampleRawThreadInfoA),
),
).toBe(true);
diff --git a/lib/shared/updates/join-thread-spec.js b/lib/shared/updates/join-thread-spec.js
--- a/lib/shared/updates/join-thread-spec.js
+++ b/lib/shared/updates/join-thread-spec.js
@@ -5,7 +5,7 @@
import t from 'tcomb';
import type { UpdateInfoFromRawInfoParams, UpdateSpec } from './update-spec.js';
-import { rawThreadInfoValidator } from '../../permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-thread-permissions-validators.js';
import {
type RawEntryInfo,
rawEntryInfoValidator,
@@ -173,7 +173,7 @@
type: tNumber(updateTypes.JOIN_THREAD),
id: t.String,
time: t.Number,
- threadInfo: rawThreadInfoValidator,
+ threadInfo: mixedRawThreadInfoValidator,
rawMessageInfos: t.list(rawMessageInfoValidator),
truncationStatus: messageTruncationStatusValidator,
rawEntryInfos: t.list(rawEntryInfoValidator),
diff --git a/lib/shared/updates/update-thread-spec.js b/lib/shared/updates/update-thread-spec.js
--- a/lib/shared/updates/update-thread-spec.js
+++ b/lib/shared/updates/update-thread-spec.js
@@ -5,7 +5,7 @@
import t from 'tcomb';
import type { UpdateInfoFromRawInfoParams, UpdateSpec } from './update-spec.js';
-import { rawThreadInfoValidator } from '../../permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-thread-permissions-validators.js';
import type { RawThreadInfos } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type {
@@ -117,6 +117,6 @@
type: tNumber(updateTypes.UPDATE_THREAD),
id: t.String,
time: t.Number,
- threadInfo: rawThreadInfoValidator,
+ threadInfo: mixedRawThreadInfoValidator,
}),
});
diff --git a/lib/types/request-types.js b/lib/types/request-types.js
--- a/lib/types/request-types.js
+++ b/lib/types/request-types.js
@@ -26,7 +26,7 @@
type AccountUserInfo,
accountUserInfoValidator,
} from './user-types.js';
-import { rawThreadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js';
import { tNumber, tShape, tID } from '../utils/validation-utils.js';
// "Server requests" are requests for information that the server delivers to
@@ -132,7 +132,7 @@
),
stateChanges: t.maybe(
tShape<StateChanges>({
- rawThreadInfos: t.maybe(t.list(rawThreadInfoValidator)),
+ rawThreadInfos: t.maybe(t.list(mixedRawThreadInfoValidator)),
rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)),
currentUserInfo: t.maybe(currentUserInfoValidator),
userInfos: t.maybe(t.list(accountUserInfoValidator)),
diff --git a/lib/types/socket-types.js b/lib/types/socket-types.js
--- a/lib/types/socket-types.js
+++ b/lib/types/socket-types.js
@@ -50,7 +50,7 @@
type LoggedOutUserInfo,
loggedOutUserInfoValidator,
} from './user-types.js';
-import { rawThreadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js';
+import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js';
import { tShape, tNumber, tID } from '../utils/validation-utils.js';
// The types of messages that the client sends across the socket
@@ -219,7 +219,7 @@
}>;
const serverFullStateSyncValidator = tShape<ServerFullStateSync>({
...baseFullStateSyncValidator.meta.props,
- threadInfos: t.dict(tID, rawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
currentUserInfo: currentUserInfoValidator,
});
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
@@ -4,7 +4,7 @@
import {
MemberInfoValidator,
- minimallyEncodedRoleInfoValidator,
+ roleInfoValidator,
threadCurrentUserInfoValidator,
} from '../permissions/minimally-encoded-thread-permissions-validators.js';
import type {
@@ -66,8 +66,7 @@
).reduce((acc: { [string]: RoleInfo }, roleID: string) => {
const roleInfo = rawRoles[roleID];
invariant(
- minimallyEncodedRoleInfoValidator.is(roleInfo) ||
- legacyRoleInfoValidator.is(roleInfo),
+ roleInfoValidator.is(roleInfo) || legacyRoleInfoValidator.is(roleInfo),
'rawRole must be valid [MinimallyEncoded/Legacy]RoleInfo',
);
acc[roleID] = roleInfo.minimallyEncoded
diff --git a/web/types/nav-types.js b/web/types/nav-types.js
--- a/web/types/nav-types.js
+++ b/web/types/nav-types.js
@@ -3,7 +3,7 @@
import type { TInterface } from 'tcomb';
import t from 'tcomb';
-import { minimallyEncodedThreadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
+import { threadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { type BaseNavInfo } from 'lib/types/nav-types.js';
import {
@@ -51,7 +51,7 @@
endDate: t.String,
tab: navigationTabValidator,
activeChatThreadID: t.maybe(tID),
- pendingThread: t.maybe(minimallyEncodedThreadInfoValidator),
+ pendingThread: t.maybe(threadInfoValidator),
settingsSection: t.maybe(navigationSettingsSectionValidator),
selectedUserList: t.maybe(t.list(accountUserInfoValidator)),
chatMode: t.maybe(navigationChatModeValidator),

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 8:19 AM (11 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2702036
Default Alt Text
D10806.diff (16 KB)

Event Timeline