Page MenuHomePhabricator

D13992.diff
No OneTemporary

D13992.diff

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<NewThreadResult>,
+newThickThread: (request: NewThickThreadRequest) => Promise<string>,
+textMessageCreationSideEffectsFunc: CreationSideEffectsFunc<RawTextMessageInfo>,
+ +invalidTokenLogOut: () => Promise<void>,
};
type State = {
+pendingUploads: PendingMultimediaUploads,
@@ -392,6 +394,9 @@
return result;
} catch (e) {
const exceptionMessage = getMessageForException(e) ?? '';
+ if (exceptionMessage === 'invalid_csat') {
+ void this.props.invalidTokenLogOut();
+ }
throw new SendMessageError(
`Exception when sending multimedia message: ${exceptionMessage}`,
localID,
@@ -915,6 +920,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 +1718,7 @@
const staffCanSee = useStaffCanSee();
const textMessageCreationSideEffectsFunc =
useMessageCreationSideEffectsFunc<RawTextMessageInfo>(messageTypes.TEXT);
+ const callInvalidTokenLogOut = useInvalidCSATLogOut();
return (
<InputStateContainer
@@ -1728,6 +1738,7 @@
dispatch={dispatch}
staffCanSee={staffCanSee}
textMessageCreationSideEffectsFunc={textMessageCreationSideEffectsFunc}
+ invalidTokenLogOut={callInvalidTokenLogOut}
/>
);
});
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<RawTextMessageInfo>,
+identityContext: ?IdentityClientContextType,
+ +invalidTokenLogOut: () => Promise<void>,
};
type WritableState = {
pendingUploads: {
@@ -558,6 +560,9 @@
return result;
} catch (e) {
const exceptionMessage = getMessageForException(e) ?? '';
+ if (exceptionMessage === 'invalid_csat') {
+ void this.props.invalidTokenLogOut();
+ }
throw new SendMessageError(
`Exception while sending multimedia message: ${exceptionMessage}`,
localID,
@@ -931,6 +936,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 +1212,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 +1224,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 +1679,7 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
const identityContext = React.useContext(IdentityClientContext);
+ const callInvalidTokenLogOut = useInvalidCSATLogOut();
const [sendCallbacks, setSendCallbacks] = React.useState<
$ReadOnlyArray<() => mixed>,
@@ -1705,6 +1721,7 @@
unregisterSendCallback={unregisterSendCallback}
textMessageCreationSideEffectsFunc={textMessageCreationSideEffectsFunc}
identityContext={identityContext}
+ invalidTokenLogOut={callInvalidTokenLogOut}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 12:14 AM (12 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697486
Default Alt Text
D13992.diff (5 KB)

Event Timeline