Page MenuHomePhabricator

D13990.diff
No OneTemporary

D13990.diff

diff --git a/keyserver/src/services/blob.js b/keyserver/src/services/blob.js
--- a/keyserver/src/services/blob.js
+++ b/keyserver/src/services/blob.js
@@ -132,7 +132,10 @@
async function removeBlobHolders(holders: $ReadOnlyArray<BlobHashAndHolder>) {
const headers = await createRequestHeaders(false);
- await removeMultipleHolders(holders, headers);
+ const removeResult = await removeMultipleHolders(holders, headers);
+ if (removeResult.result === 'invalid_csat') {
+ await clearIdentityInfo();
+ }
}
export {
diff --git a/lib/actions/holder-actions.js b/lib/actions/holder-actions.js
--- a/lib/actions/holder-actions.js
+++ b/lib/actions/holder-actions.js
@@ -3,6 +3,7 @@
import invariant from 'invariant';
import * as React from 'react';
+import { useInvalidCSATLogOut } from './user-actions.js';
import {
type AuthMetadata,
IdentityClientContext,
@@ -54,6 +55,7 @@
action: 'establish' | 'remove',
inputs: MultipleBlobHolders,
authMetadata: AuthMetadata,
+ handleInvalidCSAT?: () => Promise<void>,
): Promise<BlobServiceActionsResult> {
if (inputs.length === 0) {
return { succeeded: [], failed: [] };
@@ -73,6 +75,9 @@
}
if (response.result === 'error') {
return { succeeded: [], failed: inputs };
+ } else if (response.result === 'invalid_csat') {
+ void handleInvalidCSAT?.();
+ return { succeeded: [], failed: inputs };
}
const failedRequestsSet = new Set(
@@ -101,6 +106,7 @@
async function processHoldersAction(
input: ProcessHoldersStartedPayload,
authMetadata: AuthMetadata,
+ handleInvalidCSAT?: () => Promise<void>,
): Promise<ProcessHoldersFinishedPayload> {
const [
{ succeeded: added, failed: notAdded },
@@ -110,11 +116,13 @@
'establish',
input.holdersToAdd,
authMetadata,
+ handleInvalidCSAT,
),
performBlobServiceHolderActions(
'remove',
input.holdersToRemove,
authMetadata,
+ handleInvalidCSAT,
),
]);
return { added, notAdded, removed, notRemoved };
@@ -158,6 +166,8 @@
const identityContext = React.useContext(IdentityClientContext);
const getAuthMetadata = identityContext?.getAuthMetadata;
+ const invalidTokenLogOut = useInvalidCSATLogOut();
+
const storedHolders = useSelector(state => state.holderStore.storedHolders);
const dispatchActionPromise = useDispatchActionPromise();
@@ -205,7 +215,11 @@
holdersToAdd,
holdersToRemove,
};
- const promise = processHoldersAction(input, authMetadata);
+ const promise = processHoldersAction(
+ input,
+ authMetadata,
+ invalidTokenLogOut,
+ );
void dispatchActionPromise(
processHoldersActionTypes,
promise,
@@ -213,7 +227,7 @@
input,
);
},
- [dispatchActionPromise, getAuthMetadata, storedHolders],
+ [dispatchActionPromise, getAuthMetadata, invalidTokenLogOut, storedHolders],
);
}
diff --git a/lib/handlers/holders-handler.react.js b/lib/handlers/holders-handler.react.js
--- a/lib/handlers/holders-handler.react.js
+++ b/lib/handlers/holders-handler.react.js
@@ -9,6 +9,7 @@
processHoldersActionTypes,
type ProcessHoldersStartedPayload,
} from '../actions/holder-actions.js';
+import { useInvalidCSATLogOut } from '../actions/user-actions.js';
import { isLoggedIn } from '../selectors/user-selectors.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
@@ -21,6 +22,8 @@
const identityContext = React.useContext(IdentityClientContext);
const getAuthMetadata = identityContext?.getAuthMetadata;
+ const invalidTokenLogOut = useInvalidCSATLogOut();
+
const loggedIn = useSelector(isLoggedIn);
const storedHolders = useSelector(state => state.holderStore.storedHolders);
@@ -49,12 +52,12 @@
void dispatchActionPromise(
processHoldersActionTypes,
- processHoldersAction(input, authMetadata),
+ processHoldersAction(input, authMetadata, invalidTokenLogOut),
undefined,
input,
);
}, retryInterval),
- [getAuthMetadata, dispatchActionPromise],
+ [getAuthMetadata, dispatchActionPromise, invalidTokenLogOut],
);
const shouldStartProcessing =
diff --git a/lib/push/send-hooks.react.js b/lib/push/send-hooks.react.js
--- a/lib/push/send-hooks.react.js
+++ b/lib/push/send-hooks.react.js
@@ -334,6 +334,9 @@
const { statusText } = assignmentResult;
console.log(`Failed to assign all holders. Status text: ${statusText}`);
return;
+ } else if (assignmentResult.result === 'invalid_csat') {
+ console.log('Failed to assign all holders due to invalid CSAT.');
+ return;
}
for (const [blobHash, holder] of assignmentResult.failedRequests) {
diff --git a/lib/utils/blob-service.js b/lib/utils/blob-service.js
--- a/lib/utils/blob-service.js
+++ b/lib/utils/blob-service.js
@@ -227,6 +227,7 @@
headers: { [string]: string },
): Promise<
| { +result: 'success' }
+ | { +result: 'invalid_csat' }
| { +result: 'error', +status: number, +statusText: string }
| {
+failedRequests: $ReadOnlyArray<BlobInfo>,
@@ -248,6 +249,9 @@
);
if (!assignMultipleHoldersResponse.ok) {
+ if (responseIsInvalidCSAT(assignMultipleHoldersResponse)) {
+ return { result: 'invalid_csat' };
+ }
const { status, statusText } = assignMultipleHoldersResponse;
return { result: 'error', status, statusText };
}
@@ -274,6 +278,7 @@
instantDelete?: boolean,
): Promise<
| { +result: 'success' }
+ | { +result: 'invalid_csat' }
| { +result: 'error', +status: number, +statusText: string }
| {
+result: 'failed_requests',
@@ -296,6 +301,9 @@
);
if (!response.ok) {
+ if (responseIsInvalidCSAT(response)) {
+ return { result: 'invalid_csat' };
+ }
const { status, statusText } = response;
return { result: 'error', status, statusText };
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 5:14 AM (19 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2560053
Default Alt Text
D13990.diff (5 KB)

Event Timeline