Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3523772
D13960.id46054.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13960.id46054.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 10:13 AM (17 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2699608
Default Alt Text
D13960.id46054.diff (4 KB)
Attached To
Mode
D13960: [lib] Extract function to remove holder
Attached
Detach File
Event Timeline
Log In to Comment