From 8f2e05727f8d903b2ca58fd2361258fa6b7375e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Klocek?= Date: Fri, 30 Jun 2023 17:25:48 +0200 Subject: [PATCH] [web] Update Blob service DELETE endpoint call Summary: Depends on D8396 Updated the Blob service DELETE endpoint call on Web to use the new request format. Test Plan: Enabled blob service uploads, selected a photo to upload to chat, then deleted it by clicking the "x" button in the photo corner. The request was successful. Blob service logs: {F614093} Reviewers: atul, pklatka Reviewed By: pklatka Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D8397 --- lib/facts/blob-service.js | 2 +- web/input/input-state-container.react.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/facts/blob-service.js b/lib/facts/blob-service.js index 2ff5e13cab..35e89d3e92 100644 --- a/lib/facts/blob-service.js +++ b/lib/facts/blob-service.js @@ -19,7 +19,7 @@ const httpEndpoints = Object.freeze({ method: 'PUT', }, DELETE_BLOB: { - path: '/blob/:holder', + path: '/blob', method: 'DELETE', }, }); diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js index f58cf78725..aa485098f3 100644 --- a/web/input/input-state-container.react.js +++ b/web/input/input-state-container.react.js @@ -91,6 +91,7 @@ import { toBase64URL } from 'lib/utils/base64.js'; import { makeBlobServiceEndpointURL, isBlobServiceURI, + blobHashFromBlobServiceURI, } from 'lib/utils/blob-service.js'; import type { CallServerEndpointOptions } from 'lib/utils/call-server-endpoint.js'; import { getConfig } from 'lib/utils/config.js'; @@ -1300,8 +1301,16 @@ class InputStateContainer extends React.PureComponent { ); const endpoint = blobService.httpEndpoints.DELETE_BLOB; const holder = pendingUpload.blobHolder; - fetch(makeBlobServiceEndpointURL(endpoint, { holder }), { + const blobHash = blobHashFromBlobServiceURI(pendingUpload.uri); + fetch(makeBlobServiceEndpointURL(endpoint), { method: endpoint.method, + body: JSON.stringify({ + holder, + blob_hash: blobHash, + }), + headers: { + 'content-type': 'application/json', + }, }); } }