Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512583
D13949.id45852.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
D13949.id45852.diff
View Options
diff --git a/keyserver/src/scripts/generate-converter-from-validator.js b/keyserver/src/scripts/generate-converter-from-validator.js
--- a/keyserver/src/scripts/generate-converter-from-validator.js
+++ b/keyserver/src/scripts/generate-converter-from-validator.js
@@ -7,7 +7,7 @@
mediaValidator,
} from 'lib/types/media-types.js';
import { threadPermissionInfoValidator } from 'lib/types/thread-permission-types.js';
-import { legacyRawThreadInfoValidator } from 'lib/types/thread-types.js';
+import { legacyThinRawThreadInfoValidator } from 'lib/types/thread-types.js';
import { ashoatKeyserverID, tID } from 'lib/utils/validation-utils.js';
import { main } from './utils.js';
@@ -213,7 +213,7 @@
}
// Input arguments:
-const validator = legacyRawThreadInfoValidator;
+const validator = legacyThinRawThreadInfoValidator;
const typeName = 'RawThreadInfo';
const validatorToBeConverted = tID;
const conversionExpressionString = (inputName: string) =>
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 { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-raw-thread-info-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';
@@ -47,6 +47,10 @@
}
async function getServerInfoHash(info: LegacyRawThreadInfo | RawThreadInfo) {
- const output = await validateOutput(null, mixedRawThreadInfoValidator, info);
+ const output = await validateOutput(
+ null,
+ mixedThinRawThreadInfoValidator,
+ info,
+ );
return hash(output);
}
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
@@ -10,18 +10,18 @@
import type {
MemberInfoWithPermissions,
ThreadCurrentUserInfo,
- RawThreadInfo,
+ ThinRawThreadInfo,
RoleInfo,
RoleInfoWithoutSpecialRole,
- RawThreadInfoWithoutSpecialRole,
+ ThinRawThreadInfoWithoutSpecialRole,
MinimallyEncodedThickMemberInfo,
MemberInfoSansPermissions,
} from '../types/minimally-encoded-thread-permissions-types.js';
import { threadSubscriptionValidator } from '../types/subscription-types.js';
import {
- type LegacyRawThreadInfo,
+ type LegacyThinRawThreadInfo,
legacyMemberInfoValidator,
- legacyRawThreadInfoValidator,
+ legacyThinRawThreadInfoValidator,
legacyThreadCurrentUserInfoValidator,
} from '../types/thread-types.js';
import { tBool, tID, tShape, tUserID } from '../utils/validation-utils.js';
@@ -90,9 +90,9 @@
subscription: threadSubscriptionValidator,
});
-const rawThreadInfoValidator: TInterface<RawThreadInfo> = tShape<RawThreadInfo>(
- {
- ...legacyRawThreadInfoValidator.meta.props,
+const thinRawThreadInfoValidator: TInterface<ThinRawThreadInfo> =
+ tShape<ThinRawThreadInfo>({
+ ...legacyThinRawThreadInfoValidator.meta.props,
minimallyEncoded: tBool(true),
members: t.union([
t.list(memberInfoWithPermissionsValidator),
@@ -100,8 +100,7 @@
]),
roles: t.dict(tID, roleInfoValidator),
currentUser: threadCurrentUserInfoValidator,
- },
-);
+ });
const roleInfoWithoutSpecialRolesValidator: TInterface<RoleInfoWithoutSpecialRole> =
tShape<RoleInfoWithoutSpecialRole>({
@@ -109,18 +108,20 @@
isDefault: t.maybe(t.Boolean),
});
-const rawThreadInfoWithoutSpecialRoles: TInterface<RawThreadInfoWithoutSpecialRole> =
- tShape<RawThreadInfoWithoutSpecialRole>({
- ...rawThreadInfoValidator.meta.props,
+const thinRawThreadInfoWithoutSpecialRolesValidator: TInterface<ThinRawThreadInfoWithoutSpecialRole> =
+ tShape<ThinRawThreadInfoWithoutSpecialRole>({
+ ...thinRawThreadInfoValidator.meta.props,
roles: t.dict(tID, roleInfoWithoutSpecialRolesValidator),
});
-const mixedRawThreadInfoValidator: TUnion<
- LegacyRawThreadInfo | RawThreadInfo | RawThreadInfoWithoutSpecialRole,
+const mixedThinRawThreadInfoValidator: TUnion<
+ | LegacyThinRawThreadInfo
+ | ThinRawThreadInfo
+ | ThinRawThreadInfoWithoutSpecialRole,
> = t.union([
- legacyRawThreadInfoValidator,
- rawThreadInfoValidator,
- rawThreadInfoWithoutSpecialRoles,
+ legacyThinRawThreadInfoValidator,
+ thinRawThreadInfoValidator,
+ thinRawThreadInfoWithoutSpecialRolesValidator,
]);
export {
@@ -130,6 +131,6 @@
roleInfoValidator,
persistedRoleInfoValidator,
threadCurrentUserInfoValidator,
- rawThreadInfoValidator,
- mixedRawThreadInfoValidator,
+ thinRawThreadInfoValidator,
+ mixedThinRawThreadInfoValidator,
};
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
@@ -3,7 +3,7 @@
import {
memberInfoWithPermissionsValidator,
persistedRoleInfoValidator,
- rawThreadInfoValidator,
+ thinRawThreadInfoValidator,
roleInfoValidator,
threadCurrentUserInfoValidator,
} from './minimally-encoded-raw-thread-info-validators.js';
@@ -513,7 +513,7 @@
describe('minimallyEncodedRawThreadInfoValidator', () => {
it('should validate correctly formed MinimallyEncodedRawThreadInfo', () => {
expect(
- rawThreadInfoValidator.is(exampleMinimallyEncodedRawThreadInfoA),
+ thinRawThreadInfoValidator.is(exampleMinimallyEncodedRawThreadInfoA),
).toBe(true);
});
});
@@ -521,7 +521,7 @@
describe('minimallyEncodeRawThreadInfo', () => {
it('should correctly encode RawThreadInfo', () => {
expect(
- rawThreadInfoValidator.is(
+ thinRawThreadInfoValidator.is(
minimallyEncodeRawThreadInfoWithMemberPermissions(
exampleRawThreadInfoA,
),
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 { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
import {
type RawEntryInfo,
rawEntryInfoValidator,
@@ -173,7 +173,7 @@
type: tNumber(updateTypes.JOIN_THREAD),
id: t.String,
time: t.Number,
- threadInfo: mixedRawThreadInfoValidator,
+ threadInfo: mixedThinRawThreadInfoValidator,
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 { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
import type { RawThreadInfos } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type {
@@ -117,7 +117,7 @@
type: tNumber(updateTypes.UPDATE_THREAD),
id: t.String,
time: t.Number,
- threadInfo: mixedRawThreadInfoValidator,
+ threadInfo: mixedThinRawThreadInfoValidator,
}),
getUpdatedThreadInfo(update: ThreadUpdateInfo) {
return update.threadInfo;
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
@@ -242,8 +242,8 @@
+isDefault?: boolean,
}>;
-export type RawThreadInfoWithoutSpecialRole = $ReadOnly<{
- ...RawThreadInfo,
+export type ThinRawThreadInfoWithoutSpecialRole = $ReadOnly<{
+ ...ThinRawThreadInfo,
+roles: { +[id: string]: RoleInfoWithoutSpecialRole },
}>;
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
@@ -32,7 +32,7 @@
type AccountUserInfo,
accountUserInfoValidator,
} from './user-types.js';
-import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
import {
tNumber,
tShape,
@@ -164,7 +164,7 @@
),
stateChanges: t.maybe(
tShape<StateChanges>({
- rawThreadInfos: t.maybe(t.list(mixedRawThreadInfoValidator)),
+ rawThreadInfos: t.maybe(t.list(mixedThinRawThreadInfoValidator)),
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
@@ -54,7 +54,7 @@
type LoggedOutUserInfo,
loggedOutUserInfoValidator,
} from './user-types.js';
-import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
import { values } from '../utils/objects.js';
import { tShape, tNumber, tID } from '../utils/validation-utils.js';
@@ -224,7 +224,7 @@
}>;
const serverFullStateSyncValidator = tShape<ServerFullStateSync>({
...baseFullStateSyncValidator.meta.props,
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedThinRawThreadInfoValidator),
currentUserInfo: currentUserInfoValidator,
});
diff --git a/lib/types/thread-types-enum.js b/lib/types/thread-types-enum.js
--- a/lib/types/thread-types-enum.js
+++ b/lib/types/thread-types-enum.js
@@ -97,6 +97,10 @@
return threadType;
}
+export const thinThreadTypeValidator: TRefinement<number> = tNumEnum(
+ values(thinThreadTypes),
+);
+
export function assertThickThreadType(threadType: number): ThickThreadType {
invariant(
threadType === 13 ||
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -34,7 +34,7 @@
import {
type ThinThreadType,
type ThickThreadType,
- threadTypeValidator,
+ thinThreadTypeValidator,
} from './thread-types-enum.js';
import type { ClientUpdateInfo, ServerUpdateInfo } from './update-types.js';
import type { UserInfo, UserInfos } from './user-types.js';
@@ -180,10 +180,10 @@
export type LegacyRawThreadInfos = {
+[id: string]: LegacyRawThreadInfo,
};
-export const legacyRawThreadInfoValidator: TInterface<LegacyRawThreadInfo> =
- tShape<LegacyRawThreadInfo>({
+export const legacyThinRawThreadInfoValidator: TInterface<LegacyThinRawThreadInfo> =
+ tShape<LegacyThinRawThreadInfo>({
id: tID,
- type: threadTypeValidator,
+ type: thinThreadTypeValidator,
name: t.maybe(t.String),
avatar: t.maybe(clientAvatarValidator),
description: t.maybe(t.String),
diff --git a/lib/types/validation.test.js b/lib/types/validation.test.js
--- a/lib/types/validation.test.js
+++ b/lib/types/validation.test.js
@@ -22,7 +22,7 @@
serverUpdatesServerSocketMessageValidator,
} from './socket-types.js';
import { threadTypes } from './thread-types-enum.js';
-import { legacyRawThreadInfoValidator } from './thread-types.js';
+import { legacyThinRawThreadInfoValidator } from './thread-types.js';
import { updateTypes } from './update-types-enum.js';
import { messageSpecs } from '../shared/messages/message-specs.js';
import { updateSpecs } from '../shared/updates/update-specs.js';
@@ -633,11 +633,14 @@
describe('thread validation', () => {
it('should validate correct thread', () => {
- expect(legacyRawThreadInfoValidator.is(thread)).toBe(true);
+ expect(legacyThinRawThreadInfoValidator.is(thread)).toBe(true);
});
it('should not validate incorrect thread', () => {
expect(
- legacyRawThreadInfoValidator.is({ ...thread, creationTime: undefined }),
+ legacyThinRawThreadInfoValidator.is({
+ ...thread,
+ creationTime: undefined,
+ }),
).toBe(false);
});
});
diff --git a/lib/types/validators/redux-state-validators.js b/lib/types/validators/redux-state-validators.js
--- a/lib/types/validators/redux-state-validators.js
+++ b/lib/types/validators/redux-state-validators.js
@@ -2,7 +2,7 @@
import t, { type TInterface } from 'tcomb';
-import { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
import { tShape, tID } from '../../utils/validation-utils.js';
import { entryStoreValidator } from '../entry-types.js';
import { inviteLinksStoreValidator } from '../link-types.js';
@@ -22,7 +22,7 @@
export const threadStoreValidator: TInterface<ThreadStore> =
tShape<ThreadStore>({
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedThinRawThreadInfoValidator),
});
export const initialReduxStateValidator: TInterface<ServerWebInitialReduxStateResponse> =
diff --git a/lib/types/validators/thread-validators.js b/lib/types/validators/thread-validators.js
--- a/lib/types/validators/thread-validators.js
+++ b/lib/types/validators/thread-validators.js
@@ -3,7 +3,7 @@
import t from 'tcomb';
import type { TInterface } from 'tcomb';
-import { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
import { tShape, tID } from '../../utils/validation-utils.js';
import { mediaValidator } from '../media-types.js';
import {
@@ -69,7 +69,7 @@
export const roleModificationResultValidator: TInterface<RoleModificationResult> =
tShape<RoleModificationResult>({
- threadInfo: t.maybe(mixedRawThreadInfoValidator),
+ threadInfo: t.maybe(mixedThinRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
@@ -77,7 +77,7 @@
export const roleDeletionResultValidator: TInterface<RoleDeletionResult> =
tShape<RoleDeletionResult>({
- threadInfo: t.maybe(mixedRawThreadInfoValidator),
+ threadInfo: t.maybe(mixedThinRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
diff --git a/lib/types/validators/user-validators.js b/lib/types/validators/user-validators.js
--- a/lib/types/validators/user-validators.js
+++ b/lib/types/validators/user-validators.js
@@ -3,7 +3,7 @@
import t, { type TInterface, type TUnion, type TEnums } from 'tcomb';
import { policyTypeValidator } from '../../facts/policies.js';
-import { mixedRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
import { tShape, tID, tUserID } from '../../utils/validation-utils.js';
import type {
LogOutResponse,
@@ -38,7 +38,7 @@
rawMessageInfos: t.list(rawMessageInfoValidator),
currentUserInfo: loggedInUserInfoValidator,
cookieChange: tShape({
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedThinRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
});
@@ -57,7 +57,7 @@
rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)),
serverTime: t.Number,
cookieChange: tShape({
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedThinRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
notAcknowledgedPolicies: t.maybe(t.list<TEnums>(policyTypeValidator)),
diff --git a/lib/utils/user-info-extraction-utils.js b/lib/utils/user-info-extraction-utils.js
--- a/lib/utils/user-info-extraction-utils.js
+++ b/lib/utils/user-info-extraction-utils.js
@@ -5,7 +5,7 @@
import { processNewUserIDsActionType } from '../actions/user-actions.js';
import type { CallSingleKeyserverEndpointResponse } from '../keyserver-conn/call-single-keyserver-endpoint.js';
-import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { mixedThinRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
import type { Endpoint } from '../types/endpoints.js';
import type { Dispatch } from '../types/redux-types.js';
import type { MixedRawThreadInfos } from '../types/thread-types.js';
@@ -33,7 +33,7 @@
const additionalResponseFieldsValidator = tShape<AdditionalResponseFields>({
cookieChange: t.maybe(
tShape<AdditionalCookieChange>({
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ threadInfos: t.dict(tID, mixedThinRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
cookieInvalidated: t.maybe(t.Boolean),
sessionID: t.maybe(t.String),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 8:28 PM (12 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692381
Default Alt Text
D13949.id45852.diff (17 KB)
Attached To
Mode
D13949: [keyserver][lib] change thread info validators -> thin raw thread info validators
Attached
Detach File
Event Timeline
Log In to Comment