Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3307517
D11941.id39974.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
D11941.id39974.diff
View Options
diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -32,6 +32,8 @@
sendEditMessageResponseValidator,
sendMessageResponseValidator,
} from 'lib/types/validators/message-validators.js';
+import { initialReduxStateValidator } from 'lib/types/validators/redux-state-validators.js';
+import { relationshipErrorsValidator } from 'lib/types/validators/relationship-validators.js';
import { updateUserAvatarRequestValidator } from 'lib/utils/avatar-utils.js';
import {
@@ -101,11 +103,9 @@
import {
getInitialReduxStateResponder,
initialReduxStateRequestValidator,
- initialReduxStateValidator,
} from './responders/redux-state-responders.js';
import {
updateRelationshipsResponder,
- relationshipErrorsValidator,
updateRelationshipInputValidator,
} from './responders/relationship-responders.js';
import {
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,6 @@
import t, { type TInterface } from 'tcomb';
import { baseLegalPolicies } from 'lib/facts/policies.js';
-import { mixedRawThreadInfoValidator } from 'lib/permissions/minimally-encoded-raw-thread-info-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';
@@ -16,36 +15,24 @@
createPendingThread,
} from 'lib/shared/thread-utils.js';
import { canUseDatabaseOnWeb } from 'lib/shared/web-database.js';
-import { entryStoreValidator } from 'lib/types/entry-types.js';
import { defaultCalendarFilters } from 'lib/types/filter-types.js';
import {
- inviteLinksStoreValidator,
type CommunityLinks,
type InviteLinkWithHolder,
} from 'lib/types/link-types.js';
import {
defaultNumberPerThread,
- messageStoreValidator,
type MessageStore,
} from 'lib/types/message-types.js';
-import { webNavInfoValidator } from 'lib/types/nav-types.js';
-import type {
- WebInitialKeyserverInfo,
- ServerWebInitialReduxStateResponse,
-} from 'lib/types/redux-types.js';
+import type { ServerWebInitialReduxStateResponse } from 'lib/types/redux-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
-import { type ThreadStore } from 'lib/types/thread-types.js';
-import {
- currentUserInfoValidator,
- userInfosValidator,
- type GlobalAccountUserInfo,
-} from 'lib/types/user-types.js';
+import { type GlobalAccountUserInfo } from 'lib/types/user-types.js';
import { currentDateInTimeZone } from 'lib/utils/date-utils.js';
import { ServerError } from 'lib/utils/errors.js';
import { promiseAll } from 'lib/utils/promises.js';
import { urlInfoValidator } from 'lib/utils/url-utils.js';
-import { tShape, tID } from 'lib/utils/validation-utils.js';
+import { tShape } from 'lib/utils/validation-utils.js';
import type {
InitialReduxStateRequest,
ExcludedData,
@@ -80,29 +67,6 @@
clientUpdatesCurrentAsOf: t.Number,
});
-const initialKeyserverInfoValidator = tShape<WebInitialKeyserverInfo>({
- sessionID: t.maybe(t.String),
- updatesCurrentAsOf: t.Number,
-});
-
-export const threadStoreValidator: TInterface<ThreadStore> =
- tShape<ThreadStore>({
- threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
- });
-
-export const initialReduxStateValidator: TInterface<ServerWebInitialReduxStateResponse> =
- tShape<ServerWebInitialReduxStateResponse>({
- navInfo: webNavInfoValidator,
- currentUserInfo: currentUserInfoValidator,
- entryStore: entryStoreValidator,
- threadStore: threadStoreValidator,
- userInfos: userInfosValidator,
- messageStore: messageStoreValidator,
- pushApiPublicKey: t.maybe(t.String),
- inviteLinksStore: inviteLinksStoreValidator,
- keyserverInfo: initialKeyserverInfoValidator,
- });
-
async function getInitialReduxStateResponder(
viewer: Viewer,
request: InitialReduxStateRequest,
diff --git a/keyserver/src/responders/relationship-responders.js b/keyserver/src/responders/relationship-responders.js
--- a/keyserver/src/responders/relationship-responders.js
+++ b/keyserver/src/responders/relationship-responders.js
@@ -29,13 +29,6 @@
farcasterRelationshipRequestValidator,
]);
-export const relationshipErrorsValidator: TInterface<RelationshipErrors> =
- tShape<RelationshipErrors>({
- invalid_user: t.maybe(t.list(t.String)),
- already_friends: t.maybe(t.list(t.String)),
- user_blocked: t.maybe(t.list(t.String)),
- });
-
async function updateRelationshipsResponder(
viewer: Viewer,
request: RelationshipRequest,
diff --git a/keyserver/src/responders/responder-validators.test.js b/keyserver/src/responders/responder-validators.test.js
--- a/keyserver/src/responders/responder-validators.test.js
+++ b/keyserver/src/responders/responder-validators.test.js
@@ -23,8 +23,8 @@
sendEditMessageResponseValidator,
sendMessageResponseValidator,
} from 'lib/types/validators/message-validators.js';
+import { relationshipErrorsValidator } from 'lib/types/validators/relationship-validators.js';
-import { relationshipErrorsValidator } from './relationship-responders.js';
import { reportCreationResponseValidator } from './report-responders.js';
import { userSearchResultValidator } from './search-responders.js';
import { siweNonceResponseValidator } from './siwe-nonce-responders.js';
diff --git a/lib/types/validators/redux-state-validators.js b/lib/types/validators/redux-state-validators.js
new file mode 100644
--- /dev/null
+++ b/lib/types/validators/redux-state-validators.js
@@ -0,0 +1,39 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import { mixedRawThreadInfoValidator } 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';
+import { messageStoreValidator } from '../message-types.js';
+import { webNavInfoValidator } from '../nav-types.js';
+import type {
+ WebInitialKeyserverInfo,
+ ServerWebInitialReduxStateResponse,
+} from '../redux-types.js';
+import type { ThreadStore } from '../thread-types';
+import { currentUserInfoValidator, userInfosValidator } from '../user-types.js';
+
+const initialKeyserverInfoValidator = tShape<WebInitialKeyserverInfo>({
+ sessionID: t.maybe(t.String),
+ updatesCurrentAsOf: t.Number,
+});
+
+export const threadStoreValidator: TInterface<ThreadStore> =
+ tShape<ThreadStore>({
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ });
+
+export const initialReduxStateValidator: TInterface<ServerWebInitialReduxStateResponse> =
+ tShape<ServerWebInitialReduxStateResponse>({
+ navInfo: webNavInfoValidator,
+ currentUserInfo: currentUserInfoValidator,
+ entryStore: entryStoreValidator,
+ threadStore: threadStoreValidator,
+ userInfos: userInfosValidator,
+ messageStore: messageStoreValidator,
+ pushApiPublicKey: t.maybe(t.String),
+ inviteLinksStore: inviteLinksStoreValidator,
+ keyserverInfo: initialKeyserverInfoValidator,
+ });
diff --git a/lib/types/validators/relationship-validators.js b/lib/types/validators/relationship-validators.js
new file mode 100644
--- /dev/null
+++ b/lib/types/validators/relationship-validators.js
@@ -0,0 +1,13 @@
+// @flow
+
+import t, { type TInterface } from 'tcomb';
+
+import { tShape } from '../../utils/validation-utils.js';
+import { type RelationshipErrors } from '../relationship-types.js';
+
+export const relationshipErrorsValidator: TInterface<RelationshipErrors> =
+ tShape<RelationshipErrors>({
+ invalid_user: t.maybe(t.list(t.String)),
+ already_friends: t.maybe(t.list(t.String)),
+ user_blocked: t.maybe(t.list(t.String)),
+ });
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 20, 2:37 AM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2540782
Default Alt Text
D11941.id39974.diff (7 KB)
Attached To
Mode
D11941: [lib][keyserver] Move relationship and redux state validators to lib
Attached
Detach File
Event Timeline
Log In to Comment