Page MenuHomePhabricator

D12199.id40571.diff
No OneTemporary

D12199.id40571.diff

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
@@ -6,16 +6,32 @@
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 type { MixedRawThreadInfos } from '../types/thread-types.js';
import { userInfoValidator } from '../types/user-types.js';
+import type { UserInfo } 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';
+type AdditionalCookieChange = {
+ +threadInfos: MixedRawThreadInfos,
+ +userInfos: $ReadOnlyArray<UserInfo>,
+ +cookieInvalidated?: boolean,
+ sessionID?: string,
+ cookie?: string,
+};
+
+type AdditionalResponseFields = {
+ +cookieChange: AdditionalCookieChange,
+ +error?: string,
+ +payload?: Object,
+ +success: boolean,
+};
+
function extendResponderValidatorBase(inputValidator: TType<*>): TType<*> {
- return tShape({
- ...inputValidator.meta.props,
+ const additionalResponseFieldsValidator = tShape<AdditionalResponseFields>({
cookieChange: t.maybe(
- tShape({
+ tShape<AdditionalCookieChange>({
threadInfos: t.dict(tID, mixedRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
cookieInvalidated: t.maybe(t.Boolean),
@@ -27,6 +43,23 @@
payload: t.maybe(t.Object),
success: t.maybe(t.Boolean),
});
+
+ if (inputValidator.meta.kind === 'union') {
+ const newTypes = [];
+ for (const innerValidator of inputValidator.meta.types) {
+ const newInnerValidator = extendResponderValidatorBase(innerValidator);
+ newTypes.push(newInnerValidator);
+ }
+ // $FlowIgnore
+ inputValidator.meta.types = newTypes;
+
+ return inputValidator;
+ }
+
+ return tShape({
+ ...inputValidator.meta.props,
+ ...additionalResponseFieldsValidator.meta.props,
+ });
}
const extendResponderValidator = _memoize(extendResponderValidatorBase);

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 8:06 PM (12 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703053
Default Alt Text
D12199.id40571.diff (2 KB)

Event Timeline