diff --git a/js/models/conversations.js b/js/models/conversations.js index f86511faf..3d1ce4dcc 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -62,10 +62,15 @@ onMessageError: function() { this.updateVerified(); }, + safeGetVerified: function() { + return textsecure.storage.protocol.getVerified(this.id).catch(function() { + return textsecure.storage.protocol.VerifiedStatus.DEFAULT; + }); + }, updateVerified: function() { if (this.isPrivate()) { return Promise.all([ - textsecure.storage.protocol.getVerified(this.id), + this.safeGetVerified(), this.safeFetch() ]).then(function(results) { var trust = results[0]; @@ -220,9 +225,14 @@ return textsecure.storage.protocol.setApproval(this.id, true); }, + safeIsUntrusted: function() { + return textsecure.storage.protocol.isUntrusted(this.id).catch(function() { + return false; + }); + }, isUntrusted: function() { if (this.isPrivate()) { - return textsecure.storage.protocol.isUntrusted(this.id); + return this.safeIsUntrusted(); } else { if (!this.contactCollection.length) { return Promise.resolve(false); @@ -232,7 +242,7 @@ if (contact.isMe()) { return false; } else { - return contact.isUntrusted(); + return contact.safeIsUntrusted(); } }.bind(this))).then(function(results) { return _.any(results, function(result) { @@ -257,7 +267,7 @@ if (contact.isMe()) { return [false, contact]; } else { - return Promise.all([this.isUntrusted(), contact]); + return Promise.all([contact.isUntrusted(), contact]); } }.bind(this))).then(function(results) { results = _.filter(results, function(result) { @@ -653,6 +663,11 @@ return sessionCipher.closeOpenSessionForDevice(); } }); + }).catch(function(error) { + console.log( + 'getProfile error:', + error && error.stack ? error.stack : error + ); }); }, diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 03a09bcd7..43e4f904a 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -875,7 +875,12 @@ } this.showSendConfirmationDialog(e, contacts); - }.bind(this)); + }.bind(this)).catch(function(error) { + console.log( + 'checkUnverifiedSendMessage error:', + error && error.stack ? error.stack : error + ); + }); }, checkUntrustedSendMessage: function(e, options) { @@ -883,7 +888,6 @@ _.defaults(options, {force: false}); this.model.getUntrusted().then(function(contacts) { - if (!contacts.length) { return this.sendMessage(e); } @@ -895,7 +899,12 @@ } this.showSendConfirmationDialog(e, contacts); - }.bind(this)); + }.bind(this)).catch(function(error) { + console.log( + 'checkUntrustedSendMessage error:', + error && error.stack ? error.stack : error + ); + }); }, sendMessage: function(e) {