Fix, display (image) attachments
This commit is contained in:
parent
2820ff8f2d
commit
ee2f43aba4
4 changed files with 17 additions and 4 deletions
|
@ -89,7 +89,6 @@ window.textsecure.crypto = new function() {
|
|||
//TODO: fscking type conversion
|
||||
return Promise.resolve({ pubKey: prependVersion(toArrayBuffer(curve25519(priv))), privKey: privKey});
|
||||
}
|
||||
|
||||
}
|
||||
var privToPub = function(privKey, isIdentity) { return testing_only.privToPub(privKey, isIdentity); }
|
||||
|
||||
|
@ -580,8 +579,8 @@ window.textsecure.crypto = new function() {
|
|||
var aes_key = keys.slice(0, 32);
|
||||
var mac_key = keys.slice(32, 64);
|
||||
|
||||
var iv = encryptedBin.slice(0, 32);
|
||||
var ciphertext = encryptedBin.slice(32, encryptedBin.byteLength - 32);
|
||||
var iv = encryptedBin.slice(0, 16);
|
||||
var ciphertext = encryptedBin.slice(16, encryptedBin.byteLength - 32);
|
||||
var ivAndCiphertext = encryptedBin.slice(0, encryptedBin.byteLength - 32);
|
||||
var mac = encryptedBin.slice(encryptedBin.byteLength - 32, encryptedBin.byteLength);
|
||||
|
||||
|
|
|
@ -471,7 +471,9 @@ window.textsecure.subscribeToPush = function() {
|
|||
var promises = [];
|
||||
for (var i = 0; i < decrypted.message.attachments.length; i++)
|
||||
promises[i] = handleAttachment(decrypted.message.attachments[i]);
|
||||
return Promise.all(promises).then(message_callback);
|
||||
return Promise.all(promises).then(function() {
|
||||
message_callback(decrypted);
|
||||
});
|
||||
})
|
||||
}).catch(function(e) {
|
||||
console.log("Error handling incoming message: ");
|
||||
|
|
|
@ -15,10 +15,16 @@ var Whisper = Whisper || {};
|
|||
comparator: 'timestamp',
|
||||
|
||||
addIncomingMessage: function(decrypted) {
|
||||
//TODO: The data in decrypted (from subscribeToPush) should already be cleaned up
|
||||
var attachments = [];
|
||||
for (var i = 0; i < decrypted.message.attachments.length; i++)
|
||||
attachments[i] = "data:" + decrypted.message.attachments[i].contentType + ";base64," + btoa(getString(decrypted.message.attachments[i].decrypted));
|
||||
|
||||
var m = Whisper.Messages.add({
|
||||
person: decrypted.pushMessage.source,
|
||||
group: decrypted.message.group,
|
||||
body: decrypted.message.body,
|
||||
attachments: attachments,
|
||||
type: 'incoming',
|
||||
timestamp: decrypted.message.timestamp
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@ var Whisper = Whisper || {};
|
|||
this.$el.
|
||||
append($('<div class="bubble">').
|
||||
append($('<span class="message-text">')).
|
||||
append($('<span class="message-attachment">')).
|
||||
append($('<span class="metadata">'))
|
||||
);
|
||||
this.$el.addClass(this.model.get('type'));
|
||||
|
@ -19,6 +20,11 @@ var Whisper = Whisper || {};
|
|||
|
||||
render: function() {
|
||||
this.$el.find('.message-text').text(this.model.get('body'));
|
||||
|
||||
var attachments = this.model.get('attachments');
|
||||
for (var i = 0; i < attachments.length; i++)
|
||||
this.$el.find('.message-attachment').append('<img src="' + attachments[i] + '" />');
|
||||
|
||||
this.$el.find('.metadata').text(this.formatTimestamp());
|
||||
return this;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue