diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js --- a/keyserver/src/endpoints.js +++ b/keyserver/src/endpoints.js @@ -12,7 +12,6 @@ import { uploadMultimediaResultValidator } from 'lib/types/media-types.js'; import { getOlmSessionInitializationDataResponseValidator } from 'lib/types/request-types.js'; import { updateUserAvatarRequestValidator } from 'lib/utils/avatar-utils.js'; -import { urlInfoValidator } from 'lib/utils/url-utils.js'; import { updateActivityResponder, @@ -93,6 +92,7 @@ } from './responders/message-responders.js'; import { getInitialReduxStateResponder, + initialReduxStateRequestValidator, initialReduxStateValidator, } from './responders/redux-state-responders.js'; import { @@ -361,7 +361,7 @@ ), get_initial_redux_state: createJSONResponder( getInitialReduxStateResponder, - urlInfoValidator, + initialReduxStateRequestValidator, initialReduxStateValidator, [], ), 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 @@ -31,12 +31,14 @@ import { currentDateInTimeZone } from 'lib/utils/date-utils.js'; import { ServerError } from 'lib/utils/errors.js'; import { promiseAll } from 'lib/utils/promises.js'; -import type { URLInfo } from 'lib/utils/url-utils.js'; +import { urlInfoValidator } from 'lib/utils/url-utils.js'; import { tShape, ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { navInfoValidator } from 'web/types/nav-types.js'; import type { InitialReduxStateResponse, InitialKeyserverInfo, + InitialReduxStateRequest, + ExcludedData, } from 'web/types/redux-types.js'; import { navInfoFromURL } from 'web/url-utils.js'; @@ -54,6 +56,16 @@ import { setNewSession } from '../session/cookies.js'; import { Viewer } from '../session/viewer.js'; +const excludedDataValidator: TInterface = tShape({ + threadStore: t.maybe(t.Bool), +}); + +export const initialReduxStateRequestValidator: TInterface = + tShape({ + urlInfo: urlInfoValidator, + excludedData: excludedDataValidator, + }); + const initialKeyserverInfoValidator = tShape({ sessionID: t.maybe(t.String), updatesCurrentAsOf: t.Number, @@ -75,8 +87,9 @@ async function getInitialReduxStateResponder( viewer: Viewer, - urlInfo: URLInfo, + request: InitialReduxStateRequest, ): Promise { + const { urlInfo } = request; const hasNotAcknowledgedPoliciesPromise = hasAnyNotAcknowledgedPolicies( viewer.id, baseLegalPolicies, diff --git a/web/redux/action-types.js b/web/redux/action-types.js --- a/web/redux/action-types.js +++ b/web/redux/action-types.js @@ -4,13 +4,13 @@ import { extractKeyserverIDFromID } from 'lib/utils/action-utils.js'; import { useKeyserverCall } from 'lib/utils/keyserver-call.js'; import type { CallKeyserverEndpoint } from 'lib/utils/keyserver-call.js'; -import type { URLInfo } from 'lib/utils/url-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import type { InitialReduxState, InitialReduxStateResponse, InitialKeyserverInfo, + InitialReduxStateRequest, } from '../types/redux-types.js'; export const updateNavInfoActionType = 'UPDATE_NAV_INFO'; @@ -23,17 +23,18 @@ ( callKeyserverEndpoint: CallKeyserverEndpoint, allKeyserverIDs: $ReadOnlyArray, - ): ((input: URLInfo) => Promise) => - async urlInfo => { + ): ((input: InitialReduxStateRequest) => Promise) => + async input => { const requests = {}; + const { urlInfo, excludedData } = input; const { thread, inviteSecret, ...rest } = urlInfo; const threadKeyserverID = thread ? extractKeyserverIDFromID(thread) : null; for (const keyserverID of allKeyserverIDs) { if (keyserverID === threadKeyserverID) { - requests[keyserverID] = urlInfo; + requests[keyserverID] = { urlInfo, excludedData }; } else { - requests[keyserverID] = rest; + requests[keyserverID] = { urlInfo: rest, excludedData }; } } @@ -141,7 +142,7 @@ }; function useGetInitialReduxState(): ( - input: URLInfo, + input: InitialReduxStateRequest, ) => Promise { return useKeyserverCall(getInitialReduxState); } diff --git a/web/redux/initial-state-gate.js b/web/redux/initial-state-gate.js --- a/web/redux/initial-state-gate.js +++ b/web/redux/initial-state-gate.js @@ -47,7 +47,10 @@ thread: convertIDToNewSchema(urlInfo.thread, ashoatKeyserverID), }; } - const payload = await callGetInitialReduxState(urlInfo); + const payload = await callGetInitialReduxState({ + urlInfo, + excludedData: { threadStore: false }, + }); dispatch({ type: setInitialReduxState, payload }); } catch (err) { setInitError(err); diff --git a/web/types/redux-types.js b/web/types/redux-types.js --- a/web/types/redux-types.js +++ b/web/types/redux-types.js @@ -5,6 +5,7 @@ import type { MessageStore } from 'lib/types/message-types.js'; import type { ThreadStore } from 'lib/types/thread-types.js'; import type { CurrentUserInfo, UserInfos } from 'lib/types/user-types.js'; +import type { URLInfo } from 'lib/utils/url-utils.js'; import type { NavInfo } from '../types/nav-types.js'; @@ -40,3 +41,12 @@ +sessionID: ?string, +updatesCurrentAsOf: number, }; + +export type ExcludedData = { + +threadStore?: boolean, +}; + +export type InitialReduxStateRequest = { + +urlInfo: URLInfo, + +excludedData: ExcludedData, +};