diff --git a/lib/actions/siwe-actions.js b/lib/actions/siwe-actions.js --- a/lib/actions/siwe-actions.js +++ b/lib/actions/siwe-actions.js @@ -1,10 +1,14 @@ // @flow import threadWatcher from '../shared/thread-watcher.js'; -import type { LogInResponse } from '../types/account-types.js'; +import { + type LogInResult, + logInActionSources, +} from '../types/account-types.js'; import type { SIWEAuthServerCall } from '../types/siwe-types.js'; import type { CallServerEndpoint } from '../utils/call-server-endpoint'; import { getConfig } from '../utils/config.js'; +import { mergeUserInfos } from './user-actions.js'; const getSIWENonceActionTypes = Object.freeze({ started: 'GET_SIWE_NONCE_STARTED', @@ -28,7 +32,7 @@ callServerEndpoint: CallServerEndpoint, ): (( siweAuthPayload: SIWEAuthServerCall, -) => Promise) => async siweAuthPayload => { +) => Promise) => async siweAuthPayload => { const watchedIDs = threadWatcher.getWatchedIDs(); const response = await callServerEndpoint( 'siwe_auth', @@ -39,7 +43,27 @@ }, siweAuthCallServerEndpointOptions, ); - return response; + const userInfos = mergeUserInfos( + response.userInfos, + response.cookieChange.userInfos, + ); + return { + threadInfos: response.cookieChange.threadInfos, + currentUserInfo: response.currentUserInfo, + calendarResult: { + calendarQuery: siweAuthPayload.calendarQuery, + rawEntryInfos: response.rawEntryInfos, + }, + messagesResult: { + messageInfos: response.rawMessageInfos, + truncationStatus: response.truncationStatuses, + watchedIDsAtRequestTime: watchedIDs, + currentAsOf: response.serverTime, + }, + userInfos, + updatesCurrentAsOf: response.serverTime, + logInActionSource: logInActionSources.logInFromNativeSIWE, + }; }; export { getSIWENonceActionTypes, getSIWENonce, siweAuthActionTypes, siweAuth }; diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -242,6 +242,7 @@ deleteAccount, deleteAccountActionTypes, getSessionPublicKeys, + mergeUserInfos, logIn, logInActionTypes, logOut, diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -86,6 +86,7 @@ sqliteLoadFailure: 'SQLITE_LOAD_FAILURE', logInFromWebForm: 'LOG_IN_FROM_WEB_FORM', logInFromNativeForm: 'LOG_IN_FROM_NATIVE_FORM', + logInFromNativeSIWE: 'LOG_IN_FROM_NATIVE_SIWE', }); export type LogInActionSource = $Values; diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -7,7 +7,6 @@ LogInResult, RegisterResult, DefaultNotificationPayload, - LogInResponse, } from './account-types'; import type { ActivityUpdateSuccessPayload, @@ -902,7 +901,7 @@ } | { +type: 'SIWE_AUTH_SUCCESS', - +payload: LogInResponse, + +payload: LogInResult, +loadingInfo: LoadingInfo, } | {