From 36e8b82b5fe32b0fcdc916bf72f8eb44159ffb78 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 30 Aug 2017 14:40:08 -0700 Subject: [PATCH] Remove unknown group messages from cache - no need to retry! (#1414) FREEBIE --- js/libtextsecure.js | 7 ++++--- libtextsecure/message_receiver.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index d2ffae84b..8651517b9 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38674,7 +38674,7 @@ MessageReceiver.prototype.extend({ p = this.handleEndSession(destination); } return p.then(function() { - return this.processDecrypted(message, this.number).then(function(message) { + return this.processDecrypted(envelope, message, this.number).then(function(message) { var ev = new Event('sent'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { @@ -38698,7 +38698,7 @@ MessageReceiver.prototype.extend({ p = this.handleEndSession(envelope.source); } return p.then(function() { - return this.processDecrypted(message, envelope.source).then(function(message) { + return this.processDecrypted(envelope, message, envelope.source).then(function(message) { var ev = new Event('message'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { @@ -39008,7 +39008,7 @@ MessageReceiver.prototype.extend({ })); }); }, - processDecrypted: function(decrypted, source) { + processDecrypted: function(envelope, decrypted, source) { // Now that its decrypted, validate the message and clean it up for consumer processing // Note that messages may (generally) only perform one action and we ignore remaining fields // after the first action. @@ -39082,6 +39082,7 @@ MessageReceiver.prototype.extend({ break; default: + this.removeFromCache(envelope); throw new Error("Unknown group message type"); } } diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 2ac21c8ac..302451424 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -423,7 +423,7 @@ MessageReceiver.prototype.extend({ p = this.handleEndSession(destination); } return p.then(function() { - return this.processDecrypted(message, this.number).then(function(message) { + return this.processDecrypted(envelope, message, this.number).then(function(message) { var ev = new Event('sent'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { @@ -447,7 +447,7 @@ MessageReceiver.prototype.extend({ p = this.handleEndSession(envelope.source); } return p.then(function() { - return this.processDecrypted(message, envelope.source).then(function(message) { + return this.processDecrypted(envelope, message, envelope.source).then(function(message) { var ev = new Event('message'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { @@ -757,7 +757,7 @@ MessageReceiver.prototype.extend({ })); }); }, - processDecrypted: function(decrypted, source) { + processDecrypted: function(envelope, decrypted, source) { // Now that its decrypted, validate the message and clean it up for consumer processing // Note that messages may (generally) only perform one action and we ignore remaining fields // after the first action. @@ -831,6 +831,7 @@ MessageReceiver.prototype.extend({ break; default: + this.removeFromCache(envelope); throw new Error("Unknown group message type"); } }