Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3507420
D12072.id40365.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12072.id40365.diff
View Options
diff --git a/lib/handlers/http-message-user-infos-handler.js b/lib/handlers/http-message-user-infos-handler.js
new file mode 100644
--- /dev/null
+++ b/lib/handlers/http-message-user-infos-handler.js
@@ -0,0 +1,46 @@
+// @flow
+
+import _memoize from 'lodash/memoize.js';
+import t, { type TType } from 'tcomb';
+
+import type { CallSingleKeyserverEndpointResponse } from '../keyserver-conn/call-single-keyserver-endpoint.js';
+import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
+import type { Endpoint } from '../types/endpoints.js';
+import { userInfoValidator } from '../types/user-types.js';
+import { endpointValidators } from '../types/validators/endpoint-validators.js';
+import { extractUserIDsFromPayload } from '../utils/conversion-utils.js';
+import { tID, tShape } from '../utils/validation-utils.js';
+
+function extendResponderValidatorBase(inputValidator: TType<*>): TType<*> {
+ return tShape({
+ ...inputValidator.meta.props,
+ cookieChange: t.maybe(
+ tShape({
+ threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
+ userInfos: t.list(userInfoValidator),
+ cookieInvalidated: t.maybe(t.Boolean),
+ sessionID: t.maybe(t.String),
+ cookie: t.maybe(t.String),
+ }),
+ ),
+ error: t.maybe(t.String),
+ payload: t.maybe(t.Object),
+ success: t.maybe(t.Boolean),
+ });
+}
+
+const extendResponderValidator = _memoize(extendResponderValidatorBase);
+
+function extractAndPersistUserInfosFromEndpointResponse(
+ message: CallSingleKeyserverEndpointResponse,
+ endpoint: Endpoint,
+): void {
+ const extendedValidator = extendResponderValidator(
+ endpointValidators[endpoint].validator,
+ );
+ // eslint-disable-next-line no-unused-vars
+ const newUserIDs = extractUserIDsFromPayload(extendedValidator, message);
+ // TODO: dispatch an action adding the new user ids to the UserStore
+}
+
+export { extractAndPersistUserInfosFromEndpointResponse };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 8:45 PM (17 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2689023
Default Alt Text
D12072.id40365.diff (1 KB)
Attached To
Mode
D12072: [lib] Add httpMessageUserInfosHandler
Attached
Detach File
Event Timeline
Log In to Comment