Update proto id and use the server id as the attachmentpointer id
This commit is contained in:
parent
5710c1268c
commit
c7a91686a8
|
@ -51,7 +51,11 @@ class LokiFileServerAPI {
|
|||
}
|
||||
|
||||
const url = response.data && response.data.url;
|
||||
return url;
|
||||
const id = response.data && response.data.id;
|
||||
return {
|
||||
url,
|
||||
id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window, dcodeIO, libloki */
|
||||
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window */
|
||||
|
||||
/* eslint-disable more/no-then, no-bitwise */
|
||||
|
||||
|
@ -191,38 +191,35 @@ MessageSender.prototype = {
|
|||
return textsecure.crypto
|
||||
.encryptAttachment(attachment.data, proto.key, iv)
|
||||
.then(result =>
|
||||
this.server.putAttachment(result.ciphertext).then(async url => {
|
||||
const urlBuffer = dcodeIO.ByteBuffer.wrap(
|
||||
url,
|
||||
'utf8'
|
||||
).toArrayBuffer();
|
||||
const idBuffer = await libloki.crypto.sha512(urlBuffer);
|
||||
proto.id = dcodeIO.ByteBuffer.wrap(idBuffer).toString('base64');
|
||||
proto.url = url;
|
||||
proto.contentType = attachment.contentType;
|
||||
proto.digest = result.digest;
|
||||
this.server
|
||||
.putAttachment(result.ciphertext)
|
||||
.then(async ({ url, id }) => {
|
||||
proto.id = id;
|
||||
proto.url = url;
|
||||
proto.contentType = attachment.contentType;
|
||||
proto.digest = result.digest;
|
||||
|
||||
if (attachment.size) {
|
||||
proto.size = attachment.size;
|
||||
}
|
||||
if (attachment.fileName) {
|
||||
proto.fileName = attachment.fileName;
|
||||
}
|
||||
if (attachment.flags) {
|
||||
proto.flags = attachment.flags;
|
||||
}
|
||||
if (attachment.width) {
|
||||
proto.width = attachment.width;
|
||||
}
|
||||
if (attachment.height) {
|
||||
proto.height = attachment.height;
|
||||
}
|
||||
if (attachment.caption) {
|
||||
proto.caption = attachment.caption;
|
||||
}
|
||||
if (attachment.size) {
|
||||
proto.size = attachment.size;
|
||||
}
|
||||
if (attachment.fileName) {
|
||||
proto.fileName = attachment.fileName;
|
||||
}
|
||||
if (attachment.flags) {
|
||||
proto.flags = attachment.flags;
|
||||
}
|
||||
if (attachment.width) {
|
||||
proto.width = attachment.width;
|
||||
}
|
||||
if (attachment.height) {
|
||||
proto.height = attachment.height;
|
||||
}
|
||||
if (attachment.caption) {
|
||||
proto.caption = attachment.caption;
|
||||
}
|
||||
|
||||
return proto;
|
||||
})
|
||||
return proto;
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ message AttachmentPointer {
|
|||
optional uint32 width = 9;
|
||||
optional uint32 height = 10;
|
||||
optional string caption = 11;
|
||||
optional string url = 12;
|
||||
optional string url = 101;
|
||||
}
|
||||
|
||||
message GroupContext {
|
||||
|
|
Loading…
Reference in New Issue