diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js --- a/keyserver/src/endpoints.js +++ b/keyserver/src/endpoints.js @@ -12,6 +12,7 @@ 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, @@ -90,6 +91,10 @@ searchMessagesResponderInputValidator, searchMessagesResponseValidator, } from './responders/message-responders.js'; +import { + getInitialReduxStateResponder, + initialReduxStateValidator, +} from './responders/redux-state-responders.js'; import { updateRelationshipsResponder, relationshipErrorsValidator, @@ -557,6 +562,12 @@ versionResponseValidator, [], ), + get_initial_redux_state: createJSONResponder( + getInitialReduxStateResponder, + urlInfoValidator, + initialReduxStateValidator, + [], + ), }; export { jsonEndpoints }; diff --git a/keyserver/src/responders/redux-state-responders.js b/keyserver/src/responders/redux-state-responders.js new file mode 100644 --- /dev/null +++ b/keyserver/src/responders/redux-state-responders.js @@ -0,0 +1,55 @@ +// @flow + +import t, { type TInterface } from 'tcomb'; + +import { + entryStoreValidator, + calendarQueryValidator, +} from 'lib/types/entry-types.js'; +import { inviteLinksStoreValidator } from 'lib/types/link-types.js'; +import { messageStoreValidator } from 'lib/types/message-types.js'; +import { threadStoreValidator } from 'lib/types/thread-types.js'; +import { + currentUserInfoValidator, + userInfosValidator, +} from 'lib/types/user-types.js'; +import type { URLInfo } from 'lib/utils/url-utils.js'; +import { tShape } from 'lib/utils/validation-utils.js'; +import { navInfoValidator } from 'web/types/nav-types.js'; +import type { + InitialReduxState, + InitialKeyserverInfo, +} from 'web/types/redux-types.js'; + +import type { Viewer } from '../session/viewer'; + +const initialKeyserverInfoValidator = tShape({ + sessionID: t.maybe(t.String), + updatesCurrentAsOf: t.Number, +}); + +export const initialReduxStateValidator: TInterface = + tShape({ + navInfo: navInfoValidator, + currentUserInfo: currentUserInfoValidator, + entryStore: entryStoreValidator, + threadStore: threadStoreValidator, + userInfos: userInfosValidator, + actualizedCalendarQuery: calendarQueryValidator, + messageStore: messageStoreValidator, + pushApiPublicKey: t.maybe(t.String), + dataLoaded: t.Boolean, + commServicesAccessToken: t.Nil, + inviteLinksStore: inviteLinksStoreValidator, + keyserverInfo: initialKeyserverInfoValidator, + }); + +/* eslint-disable no-unused-vars */ +async function getInitialReduxStateResponder( + viewer: Viewer, + urlInfo: URLInfo, +): Promise { + return ({}: any); +} + +export { getInitialReduxStateResponder }; diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js --- a/lib/types/endpoints.js +++ b/lib/types/endpoints.js @@ -38,7 +38,15 @@ }); type UploadEndpoint = $Values; -type HTTPOnlyEndpoint = SessionChangingEndpoint | UploadEndpoint; +const intialReduxStateEndpoints = Object.freeze({ + GET_INITIAL_REDUX_STATE: 'get_initial_redux_state', +}); +type InitialReduxStateEndpoints = $Values; + +type HTTPOnlyEndpoint = + | SessionChangingEndpoint + | UploadEndpoint + | InitialReduxStateEndpoints; const socketOnlyEndpoints = Object.freeze({ UPDATE_ACTIVITY: 'update_activity', diff --git a/web/types/redux-types.js b/web/types/redux-types.js new file mode 100644 --- /dev/null +++ b/web/types/redux-types.js @@ -0,0 +1,29 @@ +// @flow + +import type { EntryStore, CalendarQuery } from 'lib/types/entry-types.js'; +import type { InviteLinksStore } from 'lib/types/link-types.js'; +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 { NavInfo } from '../types/nav-types.js'; + +export type InitialReduxState = { + +navInfo: NavInfo, + +currentUserInfo: CurrentUserInfo, + +entryStore: EntryStore, + +threadStore: ThreadStore, + +userInfos: UserInfos, + +actualizedCalendarQuery: CalendarQuery, + +messageStore: MessageStore, + +dataLoaded: boolean, + +pushApiPublicKey: ?string, + +commServicesAccessToken: null, + +inviteLinksStore: InviteLinksStore, + +keyserverInfo: InitialKeyserverInfo, +}; + +export type InitialKeyserverInfo = { + +sessionID: ?string, + +updatesCurrentAsOf: number, +};