diff --git a/js/models/conversations.js b/js/models/conversations.js index fd6add19..6f2f910c 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -66,14 +66,20 @@ else { sendFunc = textsecure.messaging.sendMessageToGroup; } - sendFunc(this.get('id'), body, attachments, now).catch(function(e) { - if (e.name === 'OutgoingIdentityKeyError') { - e.args.push(message.id); - message.save({ errors : [e] }).then(function() { + sendFunc(this.get('id'), body, attachments, now).catch(function(errors) { + var keyErrors = []; + _.each(errors, function(e) { + if (e.error.name === 'OutgoingIdentityKeyError') { + e.error.args.push(message.id); + keyErrors.push(e.error); + } + }); + if (keyErrors.length) { + message.save({ errors : keyErrors }).then(function() { extension.trigger('message', message); // notify frontend listeners }); } else { - throw e; + throw errors; } }); }, diff --git a/js/sendmessage.js b/js/sendmessage.js index 8657c1e6..90aee9d7 100644 --- a/js/sendmessage.js +++ b/js/sendmessage.js @@ -238,7 +238,7 @@ window.textsecure.messaging = function() { return new Promise(function(resolve, reject) { sendMessageProto(timestamp, [number], proto, function(res) { if (res.failure.length > 0) - reject(res.failure[0].error); + reject(res.failure); else resolve(); });