Revert id field and add new url field to be compatible with mobile
This commit is contained in:
parent
4e85435bf7
commit
5710c1268c
|
@ -6,6 +6,7 @@
|
|||
Multibase,
|
||||
TextEncoder,
|
||||
TextDecoder,
|
||||
crypto,
|
||||
dcodeIO
|
||||
*/
|
||||
|
||||
|
@ -180,6 +181,8 @@
|
|||
|
||||
const snodeCipher = new LokiSnodeChannel();
|
||||
|
||||
const sha512 = data => crypto.subtle.digest('SHA-512', data);
|
||||
|
||||
window.libloki.crypto = {
|
||||
DHEncrypt,
|
||||
DHDecrypt,
|
||||
|
@ -190,5 +193,6 @@
|
|||
// for testing
|
||||
_LokiSnodeChannel: LokiSnodeChannel,
|
||||
_decodeSnodeAddressToPubKey: decodeSnodeAddressToPubKey,
|
||||
sha512,
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -1438,7 +1438,7 @@ MessageReceiver.prototype.extend({
|
|||
},
|
||||
async downloadAttachment(attachment) {
|
||||
// The attachment id is actually just the absolute url of the attachment
|
||||
const encrypted = await this.server.getAttachment(attachment.id);
|
||||
const encrypted = await this.server.getAttachment(attachment.url);
|
||||
const { key, digest, size } = attachment;
|
||||
|
||||
const data = await textsecure.crypto.decryptAttachment(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window */
|
||||
/* global _, textsecure, WebAPI, libsignal, OutgoingMessage, window, dcodeIO, libloki */
|
||||
|
||||
/* eslint-disable more/no-then, no-bitwise */
|
||||
|
||||
|
@ -191,8 +191,14 @@ MessageSender.prototype = {
|
|||
return textsecure.crypto
|
||||
.encryptAttachment(attachment.data, proto.key, iv)
|
||||
.then(result =>
|
||||
this.server.putAttachment(result.ciphertext).then(url => {
|
||||
proto.id = url;
|
||||
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;
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ message AttachmentPointer {
|
|||
VOICE_MESSAGE = 1;
|
||||
}
|
||||
|
||||
optional string id = 1;
|
||||
optional fixed64 id = 1;
|
||||
optional string contentType = 2;
|
||||
optional bytes key = 3;
|
||||
optional uint32 size = 4;
|
||||
|
@ -320,6 +320,7 @@ message AttachmentPointer {
|
|||
optional uint32 width = 9;
|
||||
optional uint32 height = 10;
|
||||
optional string caption = 11;
|
||||
optional string url = 12;
|
||||
}
|
||||
|
||||
message GroupContext {
|
||||
|
|
Loading…
Reference in New Issue