Storage Service: Write

This commit is contained in:
Josh Perez 2020-09-08 20:56:23 -04:00 committed by Scott Nonnenberg
parent 8a2c17f65f
commit 1ce0959fa1
15 changed files with 1374 additions and 540 deletions

View file

@ -701,6 +701,7 @@ export type WebAPIType = {
targetUrl: string,
options?: ProxiedRequestOptionsType
) => Promise<any>;
modifyStorageRecords: MessageSender['modifyStorageRecords'];
putAttachment: (encryptedBin: ArrayBuffer) => Promise<any>;
registerCapabilities: (capabilities: any) => Promise<void>;
putStickers: (
@ -860,6 +861,7 @@ export function initialize({
getStorageRecords,
getUuidsForE164s,
makeProxiedRequest,
modifyStorageRecords,
putAttachment,
registerCapabilities,
putStickers,
@ -1012,6 +1014,25 @@ export function initialize({
});
}
async function modifyStorageRecords(
data: ArrayBuffer,
options: StorageServiceCallOptionsType = {}
): Promise<ArrayBuffer> {
const { credentials } = options;
return _ajax({
call: 'storageModify',
contentType: 'application/x-protobuf',
data,
host: storageUrl,
httpType: 'PUT',
// If we run into a conflict, the current manifest is returned -
// it will will be an ArrayBuffer at the response key on the Error
responseType: 'arraybuffer',
...credentials,
});
}
async function registerSupportForUnauthenticatedDelivery() {
return _ajax({
call: 'supportUnauthenticatedDelivery',