diff --git a/js/background.js b/js/background.js index 3ace24a03..e0bb7dd2f 100644 --- a/js/background.js +++ b/js/background.js @@ -110,7 +110,6 @@ )); }).catch(function(e) { if (e.name === 'IncomingIdentityKeyError') { - e.args.push(message.id); message.save({ errors : [e] }).then(function() { extension.trigger('message', message); notifyConversation(message); diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 4e2410c9d..36aa17be0 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37819,18 +37819,11 @@ window.axolotl.sessions = { } }; - var wipeIdentityAndTryMessageAgain = function(from, encodedMessage, message_id) { + var wipeIdentityAndTryMessageAgain = function(from, encodedMessage) { // Wipe identity key! textsecure.storage.devices.removeIdentityKeyForNumber(from.split('.')[0]); //TODO: Probably breaks with a devicecontrol message - return textsecure.protocol_wrapper.handlePreKeyWhisperMessage(from, encodedMessage).then(decodeMessageContents).then( - function(pushMessageContent) { - extension.trigger('message:decrypted', { - message_id : message_id, - data : pushMessageContent - }); - } - ); + return textsecure.protocol_wrapper.handlePreKeyWhisperMessage(from, encodedMessage).then(decodeMessageContents); } textsecure.replay.registerFunction(wipeIdentityAndTryMessageAgain, textsecure.replay.Type.INIT_SESSION); })(); @@ -39451,20 +39444,15 @@ window.textsecure.messaging = function() { } } - var tryMessageAgain = function(number, encodedMessage, message_id) { - var message = new Whisper.MessageCollection().add({id: message_id}); - message.fetch().then(function() { - //TODO: Encapsuate with the rest of textsecure.storage.devices - textsecure.storage.devices.removeIdentityKeyForNumber(number); - var proto = textsecure.protobuf.PushMessageContent.decode(encodedMessage, 'binary'); - sendMessageProto(message.get('sent_at'), [number], proto, function(res) { + var tryMessageAgain = function(number, encodedMessage, timestamp) { + textsecure.storage.devices.removeIdentityKeyForNumber(number); + var proto = textsecure.protobuf.PushMessageContent.decode(encodedMessage, 'binary'); + return new Promise(function(resolve, reject) { + sendMessageProto(timestamp, [number], proto, function(res) { if (res.failure.length > 0) - message.set('errors', res.failure); + reject(res.failure); else - message.set('errors', []); - message.save().then(function(){ - extension.trigger('message', message); // notify frontend listeners - }); + resolve(); }); }); }; @@ -39525,7 +39513,7 @@ window.textsecure.messaging = function() { if (error.message !== "Identity key changed") registerError(number, "Failed to reload device keys", error); else { - error = new textsecure.OutgoingIdentityKeyError(number, getString(message.encode())); + error = new textsecure.OutgoingIdentityKeyError(number, getString(message.encode()), timestamp); registerError(number, "Identity key changed", error); } }); diff --git a/js/models/conversations.js b/js/models/conversations.js index 487011880..0f8cb3bba 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -97,7 +97,6 @@ var keyErrors = []; _.each(errors, function(e) { if (e.error.name === 'OutgoingIdentityKeyError') { - e.error.args.push(message.id); keyErrors.push(e.error); } }); diff --git a/libtextsecure/axolotl_wrapper.js b/libtextsecure/axolotl_wrapper.js index a35ba87bf..888b265bb 100644 --- a/libtextsecure/axolotl_wrapper.js +++ b/libtextsecure/axolotl_wrapper.js @@ -119,18 +119,11 @@ } }; - var wipeIdentityAndTryMessageAgain = function(from, encodedMessage, message_id) { + var wipeIdentityAndTryMessageAgain = function(from, encodedMessage) { // Wipe identity key! textsecure.storage.devices.removeIdentityKeyForNumber(from.split('.')[0]); //TODO: Probably breaks with a devicecontrol message - return textsecure.protocol_wrapper.handlePreKeyWhisperMessage(from, encodedMessage).then(decodeMessageContents).then( - function(pushMessageContent) { - extension.trigger('message:decrypted', { - message_id : message_id, - data : pushMessageContent - }); - } - ); + return textsecure.protocol_wrapper.handlePreKeyWhisperMessage(from, encodedMessage).then(decodeMessageContents); } textsecure.replay.registerFunction(wipeIdentityAndTryMessageAgain, textsecure.replay.Type.INIT_SESSION); })(); diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 95c829ccb..beac7f806 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -127,20 +127,15 @@ window.textsecure.messaging = function() { } } - var tryMessageAgain = function(number, encodedMessage, message_id) { - var message = new Whisper.MessageCollection().add({id: message_id}); - message.fetch().then(function() { - //TODO: Encapsuate with the rest of textsecure.storage.devices - textsecure.storage.devices.removeIdentityKeyForNumber(number); - var proto = textsecure.protobuf.PushMessageContent.decode(encodedMessage, 'binary'); - sendMessageProto(message.get('sent_at'), [number], proto, function(res) { + var tryMessageAgain = function(number, encodedMessage, timestamp) { + textsecure.storage.devices.removeIdentityKeyForNumber(number); + var proto = textsecure.protobuf.PushMessageContent.decode(encodedMessage, 'binary'); + return new Promise(function(resolve, reject) { + sendMessageProto(timestamp, [number], proto, function(res) { if (res.failure.length > 0) - message.set('errors', res.failure); + reject(res.failure); else - message.set('errors', []); - message.save().then(function(){ - extension.trigger('message', message); // notify frontend listeners - }); + resolve(); }); }); }; @@ -201,7 +196,7 @@ window.textsecure.messaging = function() { if (error.message !== "Identity key changed") registerError(number, "Failed to reload device keys", error); else { - error = new textsecure.OutgoingIdentityKeyError(number, getString(message.encode())); + error = new textsecure.OutgoingIdentityKeyError(number, getString(message.encode()), timestamp); registerError(number, "Identity key changed", error); } });