Storage Service: Write
This commit is contained in:
parent
8a2c17f65f
commit
1ce0959fa1
15 changed files with 1374 additions and 540 deletions
|
@ -823,7 +823,35 @@ export default class MessageSender {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async sendRequestKeySyncMessage(options: SendOptionsType) {
|
||||
async sendFetchManifestSyncMessage(options?: SendOptionsType) {
|
||||
const myUuid = window.textsecure.storage.user.getUuid();
|
||||
const myNumber = window.textsecure.storage.user.getNumber();
|
||||
const myDevice = window.textsecure.storage.user.getDeviceId();
|
||||
|
||||
if (myDevice === 1 || myDevice === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
const fetchLatest = new window.textsecure.protobuf.SyncMessage.FetchLatest();
|
||||
fetchLatest.type =
|
||||
window.textsecure.protobuf.SyncMessage.FetchLatest.Type.STORAGE_MANIFEST;
|
||||
|
||||
const syncMessage = this.createSyncMessage();
|
||||
syncMessage.fetchLatest = fetchLatest;
|
||||
const contentMessage = new window.textsecure.protobuf.Content();
|
||||
contentMessage.syncMessage = syncMessage;
|
||||
|
||||
const silent = true;
|
||||
await this.sendIndividualProto(
|
||||
myUuid || myNumber,
|
||||
contentMessage,
|
||||
Date.now(),
|
||||
silent,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
async sendRequestKeySyncMessage(options?: SendOptionsType) {
|
||||
const myUuid = window.textsecure.storage.user.getUuid();
|
||||
const myNumber = window.textsecure.storage.user.getNumber();
|
||||
const myDevice = window.textsecure.storage.user.getDeviceId();
|
||||
|
@ -1694,4 +1722,11 @@ export default class MessageSender {
|
|||
): Promise<ArrayBuffer> {
|
||||
return this.server.getStorageRecords(data, options);
|
||||
}
|
||||
|
||||
async modifyStorageRecords(
|
||||
data: ArrayBuffer,
|
||||
options: StorageServiceCallOptionsType
|
||||
): Promise<ArrayBuffer> {
|
||||
return this.server.modifyStorageRecords(data, options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue