Page MenuHomePhabricator

D10098.id36847.diff
No OneTemporary

D10098.id36847.diff

diff --git a/keyserver/src/push/utils.js b/keyserver/src/push/utils.js
--- a/keyserver/src/push/utils.js
+++ b/keyserver/src/push/utils.js
@@ -408,7 +408,10 @@
try {
const { encryptionKey, encryptedPayload, encryptedPayloadHash } =
await encryptBlobPayload(payload);
- await upload(encryptedPayload, encryptedPayloadHash, blobHolder);
+ await upload(encryptedPayload, {
+ hash: encryptedPayloadHash,
+ holder: blobHolder,
+ });
return {
blobHash: encryptedPayloadHash,
encryptionKey,
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
@@ -31,6 +31,11 @@
};
}
+type BlobDescriptor = {
+ +hash: string,
+ +holder: string,
+};
+
async function uploadBlob(blob: Blob, hash: string): Promise<void> {
const formData = new FormData();
formData.append('blob_hash', hash);
@@ -52,7 +57,8 @@
}
}
-async function assignHolder(holder: string, hash: string): Promise<void> {
+async function assignHolder(params: BlobDescriptor): Promise<void> {
+ const { hash, holder } = params;
const headers = await createRequestHeaders();
const assignHolderResponse = await fetch(
makeBlobServiceEndpointURL(blobService.httpEndpoints.ASSIGN_HOLDER),
@@ -74,9 +80,10 @@
}
}
-async function upload(blob: Blob, hash: string, holder: string): Promise<void> {
+async function upload(blob: Blob, params: BlobDescriptor): Promise<void> {
+ const { hash, holder } = params;
try {
- await Promise.all([assignHolder(holder, hash), uploadBlob(blob, hash)]);
+ await Promise.all([assignHolder({ hash, holder }), uploadBlob(blob, hash)]);
} catch (e) {
throw new Error(
`Payload upload failed with: ${
@@ -109,11 +116,7 @@
return { found: true, blob };
}
-type DeleteBlobParams = {
- +hash: string,
- +holder: string,
-};
-async function deleteBlob(params: DeleteBlobParams, instant?: boolean) {
+async function deleteBlob(params: BlobDescriptor, instant?: boolean) {
const { hash, holder } = params;
const endpoint = blobService.httpEndpoints.DELETE_BLOB;
const url = makeBlobServiceEndpointURL(endpoint);

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 4:06 PM (9 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698864
Default Alt Text
D10098.id36847.diff (2 KB)

Event Timeline