Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32168871
D15066.1765055279.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D15066.1765055279.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
@@ -11,9 +11,8 @@
MemberInfoWithPermissions,
ThreadCurrentUserInfo,
ThinRawThreadInfo,
+ ThickRawThreadInfo,
RoleInfo,
- RoleInfoWithoutSpecialRole,
- ThinRawThreadInfoWithoutSpecialRole,
MinimallyEncodedThickMemberInfo,
MemberInfoSansPermissions,
} from '../types/minimally-encoded-thread-permissions-types.js';
@@ -23,6 +22,7 @@
legacyMemberInfoValidator,
legacyThinRawThreadInfoValidator,
legacyThreadCurrentUserInfoValidator,
+ legacyThickRawThreadInfoValidator,
} from '../types/thread-types.js';
import { tBool, tID, tShape, tUserID } from '../utils/validation-utils.js';
@@ -102,27 +102,21 @@
currentUser: threadCurrentUserInfoValidator,
});
-const roleInfoWithoutSpecialRolesValidator: TInterface<RoleInfoWithoutSpecialRole> =
- tShape<RoleInfoWithoutSpecialRole>({
- ...roleInfoValidatorBase,
- isDefault: t.maybe(t.Boolean),
- });
-
-const thinRawThreadInfoWithoutSpecialRolesValidator: TInterface<ThinRawThreadInfoWithoutSpecialRole> =
- tShape<ThinRawThreadInfoWithoutSpecialRole>({
- ...thinRawThreadInfoValidator.meta.props,
- roles: t.dict(tID, roleInfoWithoutSpecialRolesValidator),
+const thickRawThreadInfoValidator: TInterface<ThickRawThreadInfo> =
+ tShape<ThickRawThreadInfo>({
+ ...legacyThickRawThreadInfoValidator.meta.props,
+ minimallyEncoded: tBool(true),
+ members: t.list(minimallyEncodedThickMemberInfoValidator),
+ roles: t.dict(tID, roleInfoValidator),
+ currentUser: threadCurrentUserInfoValidator,
});
const mixedThinRawThreadInfoValidator: TUnion<
- | LegacyThinRawThreadInfo
- | ThinRawThreadInfo
- | ThinRawThreadInfoWithoutSpecialRole,
-> = t.union([
- legacyThinRawThreadInfoValidator,
- thinRawThreadInfoValidator,
- thinRawThreadInfoWithoutSpecialRolesValidator,
-]);
+ LegacyThinRawThreadInfo | ThinRawThreadInfo,
+> = t.union([legacyThinRawThreadInfoValidator, thinRawThreadInfoValidator]);
+
+const rawThreadInfoValidator: TUnion<ThinRawThreadInfo | ThickRawThreadInfo> =
+ t.union([thinRawThreadInfoValidator, thickRawThreadInfoValidator]);
export {
memberInfoWithPermissionsValidator,
@@ -133,4 +127,5 @@
threadCurrentUserInfoValidator,
thinRawThreadInfoValidator,
mixedThinRawThreadInfoValidator,
+ rawThreadInfoValidator,
};
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
@@ -237,16 +237,6 @@
}
};
-export type RoleInfoWithoutSpecialRole = $ReadOnly<{
- ...RoleInfoBase,
- +isDefault?: boolean,
-}>;
-
-export type ThinRawThreadInfoWithoutSpecialRole = $ReadOnly<{
- ...ThinRawThreadInfo,
- +roles: { +[id: string]: RoleInfoWithoutSpecialRole },
-}>;
-
export type RelativeMemberInfo = {
+id: string,
+role: ?string,
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,13 +26,14 @@
entryInconsistencyReportValidatorShape,
} from './report-types.js';
import type { LegacyRawThreadInfo } from './thread-types.js';
+import { legacyThreadInfoValidator } from './thread-types.js';
import {
type CurrentUserInfo,
currentUserInfoValidator,
type AccountUserInfo,
accountUserInfoValidator,
} from './user-types.js';
-import { mixedThinRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { rawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
import {
tNumber,
tShape,
@@ -136,7 +137,7 @@
}>;
type StateChanges = Partial<{
- +rawThreadInfos: LegacyRawThreadInfo[] | RawThreadInfo[],
+ +rawThreadInfos: (LegacyRawThreadInfo | RawThreadInfo)[],
+rawEntryInfos: RawEntryInfo[],
+currentUserInfo: CurrentUserInfo,
+userInfos: AccountUserInfo[],
@@ -164,7 +165,9 @@
),
stateChanges: t.maybe(
tShape<StateChanges>({
- rawThreadInfos: t.maybe(t.list(mixedThinRawThreadInfoValidator)),
+ rawThreadInfos: t.maybe(
+ t.list(t.union([legacyThreadInfoValidator, rawThreadInfoValidator])),
+ ),
rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)),
currentUserInfo: t.maybe(currentUserInfoValidator),
userInfos: t.maybe(t.list(accountUserInfoValidator)),
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
@@ -1,6 +1,6 @@
// @flow
-import t, { type TInterface } from 'tcomb';
+import t, { type TInterface, type TUnion } from 'tcomb';
import {
type AvatarDBContent,
@@ -35,12 +35,13 @@
type ThinThreadType,
type ThickThreadType,
thinThreadTypeValidator,
+ thickThreadTypeValidator,
} from './thread-types-enum.js';
import type { ClientUpdateInfo, ServerUpdateInfo } from './update-types.js';
import type { UserInfo, UserInfos } from './user-types.js';
import type { SpecialRole } from '../permissions/special-roles.js';
import { type ThreadEntity } from '../utils/entity-text.js';
-import { tID, tShape, tUserID } from '../utils/validation-utils.js';
+import { tID, tShape, tUserID, tBool } from '../utils/validation-utils.js';
export type LegacyMemberInfo = {
+id: string,
@@ -200,6 +201,43 @@
pinnedCount: t.maybe(t.Number),
});
+export const thickMemberInfoValidator: TInterface<ThickMemberInfo> =
+ tShape<ThickMemberInfo>({
+ id: tUserID,
+ role: t.maybe(tID),
+ permissions: threadPermissionsInfoValidator,
+ subscription: threadSubscriptionValidator,
+ isSender: t.Boolean,
+ });
+
+export const legacyThickRawThreadInfoValidator: TInterface<LegacyThickRawThreadInfo> =
+ tShape<LegacyThickRawThreadInfo>({
+ thick: tBool(true),
+ id: tID,
+ type: thickThreadTypeValidator,
+ name: t.maybe(t.String),
+ avatar: t.maybe(clientAvatarValidator),
+ description: t.maybe(t.String),
+ color: t.String,
+ creationTime: t.Number,
+ parentThreadID: t.maybe(tID),
+ containingThreadID: t.maybe(tID),
+ members: t.list(thickMemberInfoValidator),
+ roles: t.dict(tID, clientLegacyRoleInfoValidator),
+ currentUser: legacyThreadCurrentUserInfoValidator,
+ sourceMessageID: t.maybe(tID),
+ repliesCount: t.Number,
+ pinnedCount: t.maybe(t.Number),
+ timestamps: threadTimestampsValidator,
+ });
+
+export const legacyThreadInfoValidator: TUnion<
+ LegacyThinRawThreadInfo | LegacyThickRawThreadInfo,
+> = t.union([
+ legacyThinRawThreadInfoValidator,
+ legacyThickRawThreadInfoValidator,
+]);
+
export type MixedRawThreadInfos = {
+[id: string]: LegacyRawThreadInfo | RawThreadInfo,
};
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 { mixedThinRawThreadInfoValidator } from '../../permissions/minimally-encoded-raw-thread-info-validators.js';
+import { rawThreadInfoValidator } 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, mixedThinRawThreadInfoValidator),
+ threadInfos: t.dict(tID, rawThreadInfoValidator),
});
export const initialReduxStateValidator: TInterface<ServerWebInitialReduxStateResponse> =
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 6, 9:07 PM (19 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840868
Default Alt Text
D15066.1765055279.diff (7 KB)
Attached To
Mode
D15066: [Flow262][skip-ci] Fix thread infos validators
Attached
Detach File
Event Timeline
Log In to Comment