Page MenuHomePhabricator

D13960.diff
No OneTemporary

D13960.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
@@ -1,10 +1,9 @@
// @flow
-import blobService from 'lib/facts/blob-service.js';
import type { BlobHashAndHolder } from 'lib/types/holder-types.js';
import {
- makeBlobServiceEndpointURL,
downloadBlob,
+ removeBlobHolder,
assignBlobHolder,
} from 'lib/utils/blob-service.js';
import {
@@ -107,19 +106,9 @@
}
async function deleteBlob(params: BlobDescriptor, instant?: boolean) {
- const { hash, holder } = params;
- const endpoint = blobService.httpEndpoints.DELETE_BLOB;
- const url = makeBlobServiceEndpointURL(endpoint);
+ const { hash: blobHash, holder } = params;
const headers = await createRequestHeaders();
- await fetch(url, {
- method: endpoint.method,
- body: JSON.stringify({
- holder,
- blob_hash: hash,
- instant_delete: !!instant,
- }),
- headers,
- });
+ await removeBlobHolder({ blobHash, holder }, headers, instant);
}
async function removeBlobHolders(holders: $ReadOnlyArray<BlobHashAndHolder>) {
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
@@ -171,6 +171,34 @@
return { success: true, response };
}
+async function removeBlobHolder(
+ blobInfo: BlobInfo,
+ headers: { [string]: string },
+ instantDelete?: boolean,
+): Promise<BlobOperationResult> {
+ const { blobHash, holder } = blobInfo;
+ const endpoint = blobServiceConfig.httpEndpoints.DELETE_BLOB;
+ const response = await fetch(makeBlobServiceEndpointURL(endpoint), {
+ method: endpoint.method,
+ body: JSON.stringify({
+ holder,
+ blob_hash: blobHash,
+ instant_delete: !!instantDelete,
+ }),
+ headers: {
+ ...headers,
+ 'content-type': 'application/json',
+ },
+ });
+
+ if (!response.ok) {
+ const { status, statusText } = response;
+ return { success: false, reason: 'OTHER', status, statusText };
+ }
+
+ return { success: true, response };
+}
+
async function assignMultipleHolders(
holders: $ReadOnlyArray<BlobInfo>,
headers: { [string]: string },
@@ -273,6 +301,7 @@
downloadBlob,
uploadBlob,
assignBlobHolder,
+ removeBlobHolder,
assignMultipleHolders,
removeMultipleHolders,
};
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
@@ -28,7 +28,6 @@
type PushModal,
useModalContext,
} from 'lib/components/modal-provider.react.js';
-import blobService from 'lib/facts/blob-service.js';
import {
type SendMultimediaMessagePayload,
useInputStateContainerSendMultimediaMessage,
@@ -85,7 +84,7 @@
import {
blobHashFromBlobServiceURI,
isBlobServiceURI,
- makeBlobServiceEndpointURL,
+ removeBlobHolder,
} from 'lib/utils/blob-service.js';
import { getConfig } from 'lib/utils/config.js';
import { getMessageForException, SendMessageError } from 'lib/utils/errors.js';
@@ -1210,24 +1209,13 @@
pendingUpload.blobHolder,
'blob service upload has no holder',
);
- const endpoint = blobService.httpEndpoints.DELETE_BLOB;
const holder = pendingUpload.blobHolder;
const blobHash = blobHashFromBlobServiceURI(pendingUpload.uri);
void (async () => {
const authMetadata = await identityContext.getAuthMetadata();
const defaultHeaders =
createDefaultHTTPRequestHeaders(authMetadata);
- await fetch(makeBlobServiceEndpointURL(endpoint), {
- method: endpoint.method,
- body: JSON.stringify({
- holder,
- blob_hash: blobHash,
- }),
- headers: {
- ...defaultHeaders,
- 'content-type': 'application/json',
- },
- });
+ await removeBlobHolder({ blobHash, holder }, defaultHeaders);
})();
}
}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 5:54 PM (21 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2539974
Default Alt Text
D13960.diff (4 KB)

Event Timeline