Fix a couple things broken in d9bf0a4

Slight revert from said commit. We really do need the
IncomingPushMessageSignal protobuf at the UI layer, mostly because
it contains the 'source' attribute, without which we don't know
who sent the message.

Also fix a crash when there are no attachments on a message.
pull/749/head
lilia 11 years ago
parent 6064afd43d
commit 1e672030de

@ -603,7 +603,9 @@ window.textsecure.crypto = new function() {
case 0: //TYPE_MESSAGE_PLAINTEXT
return Promise.resolve(decodePushMessageContentProtobuf(getString(proto.message)));
case 1: //TYPE_MESSAGE_CIPHERTEXT
return decryptWhisperMessage(proto.source, getString(proto.message));
return decryptWhisperMessage(proto.source, getString(proto.message)).then(function(result) {
return {message:result, pushMessage: proto};
});
case 3: //TYPE_MESSAGE_PREKEY_BUNDLE
if (proto.message.readUint8() != (2 << 4 | 2))
throw new Error("Bad version byte");
@ -612,7 +614,7 @@ window.textsecure.crypto = new function() {
return decryptWhisperMessage(proto.source, getString(preKeyProto.message), sessions[0]).then(function(result) {
if (sessions[1] !== undefined)
crypto_storage.saveSession(proto.source, sessions[1]);
return result;
return {message: result, pushMessage:proto};
});
});
}

@ -22,8 +22,10 @@ var Whisper = Whisper || {};
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] + '" />');
if (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…
Cancel
Save