diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js --- a/native/input/input-state-container.react.js +++ b/native/input/input-state-container.react.js @@ -19,6 +19,7 @@ updateMultimediaMessageMediaActionType, useBlobServiceUpload, } from 'lib/actions/upload-actions.js'; +import { useInvalidCSATLogOut } from 'lib/actions/user-actions.js'; import { type SendMultimediaMessagePayload, useInputStateContainerSendMultimediaMessage, @@ -158,6 +159,7 @@ ) => Promise, +newThickThread: (request: NewThickThreadRequest) => Promise, +textMessageCreationSideEffectsFunc: CreationSideEffectsFunc, + +invalidTokenLogOut: () => Promise, }; type State = { +pendingUploads: PendingMultimediaUploads, @@ -915,6 +917,10 @@ mediaMissionResult = { success: true }; } catch (e) { uploadExceptionMessage = getMessageForException(e); + if (uploadExceptionMessage === 'invalid_csat') { + void this.props.invalidTokenLogOut(); + return undefined; + } onUploadFailed('upload failed'); mediaMissionResult = { success: false, @@ -1709,6 +1715,7 @@ const staffCanSee = useStaffCanSee(); const textMessageCreationSideEffectsFunc = useMessageCreationSideEffectsFunc(messageTypes.TEXT); + const callInvalidTokenLogOut = useInvalidCSATLogOut(); return ( ); }); diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -24,6 +24,7 @@ useBlobServiceUpload, useDeleteUpload, } from 'lib/actions/upload-actions.js'; +import { useInvalidCSATLogOut } from 'lib/actions/user-actions.js'; import { type PushModal, useModalContext, @@ -157,6 +158,7 @@ +unregisterSendCallback: (() => mixed) => void, +textMessageCreationSideEffectsFunc: CreationSideEffectsFunc, +identityContext: ?IdentityClientContextType, + +invalidTokenLogOut: () => Promise, }; type WritableState = { pendingUploads: { @@ -931,6 +933,10 @@ }); } catch (e) { uploadExceptionMessage = getMessageForException(e); + if (uploadExceptionMessage === 'invalid_csat') { + void this.props.invalidTokenLogOut(); + return; + } this.handleUploadFailure(threadID, localID); } userTime = Date.now() - selectTime; @@ -1203,7 +1209,7 @@ }); } if (isBlobServiceURI(pendingUpload.uri)) { - const identityContext = this.props.identityContext; + const { invalidTokenLogOut, identityContext } = this.props; invariant(identityContext, 'Identity context should be set'); invariant( pendingUpload.blobHolder, @@ -1215,7 +1221,13 @@ const authMetadata = await identityContext.getAuthMetadata(); const defaultHeaders = createDefaultHTTPRequestHeaders(authMetadata); - await removeBlobHolder({ blobHash, holder }, defaultHeaders); + const result = await removeBlobHolder( + { blobHash, holder }, + defaultHeaders, + ); + if (!result.success && result.reason === 'INVALID_CSAT') { + void invalidTokenLogOut(); + } })(); } } @@ -1664,6 +1676,7 @@ const dispatchActionPromise = useDispatchActionPromise(); const modalContext = useModalContext(); const identityContext = React.useContext(IdentityClientContext); + const callInvalidTokenLogOut = useInvalidCSATLogOut(); const [sendCallbacks, setSendCallbacks] = React.useState< $ReadOnlyArray<() => mixed>, @@ -1705,6 +1718,7 @@ unregisterSendCallback={unregisterSendCallback} textMessageCreationSideEffectsFunc={textMessageCreationSideEffectsFunc} identityContext={identityContext} + invalidTokenLogOut={callInvalidTokenLogOut} /> ); });