From 28aed8247f749dc71afc7e4f6b6efb25a2f9f03e Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 4 Oct 2019 10:30:43 -0700 Subject: [PATCH] MessageReceiver: Remove contact/group sync from cache immediately --- js/background.js | 3 +-- libtextsecure/message_receiver.js | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/js/background.js b/js/background.js index 7c9ccbc69f..6275bc6f43 100644 --- a/js/background.js +++ b/js/background.js @@ -1379,6 +1379,7 @@ } window.Signal.Data.updateConversation(id, conversation.attributes); + const { expireTimer } = details; const isValidExpireTimer = typeof expireTimer === 'number'; if (!isValidExpireTimer) { @@ -1390,8 +1391,6 @@ await conversation.updateExpirationTimer(expireTimer, source, receivedAt, { fromSync: true, }); - - ev.confirm(); } // Descriptors diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 6d6284fae6..35c5b874d7 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1040,6 +1040,8 @@ MessageReceiver.prototype.extend({ } else if (syncMessage.viewOnceOpen) { return this.handleViewOnceOpen(envelope, syncMessage.viewOnceOpen); } + + this.removeFromCache(envelope); throw new Error('Got empty SyncMessage'); }, handleConfiguration(envelope, configuration) { @@ -1100,6 +1102,8 @@ MessageReceiver.prototype.extend({ window.log.info('contact sync'); const { blob } = contacts; + this.removeFromCache(envelope); + // Note: we do not return here because we don't want to block the next message on // this attachment download and a lot of processing of that attachment. this.handleAttachment(blob).then(attachmentPointer => { @@ -1119,7 +1123,6 @@ MessageReceiver.prototype.extend({ return Promise.all(results).then(() => { window.log.info('handleContacts: finished'); - return this.removeFromCache(envelope); }); }); }, @@ -1127,6 +1130,8 @@ MessageReceiver.prototype.extend({ window.log.info('group sync'); const { blob } = groups; + this.removeFromCache(envelope); + // Note: we do not return here because we don't want to block the next message on // this attachment download and a lot of processing of that attachment. this.handleAttachment(blob).then(attachmentPointer => { @@ -1136,7 +1141,6 @@ MessageReceiver.prototype.extend({ while (groupDetails !== undefined) { groupDetails.id = groupDetails.id.toBinary(); const ev = new Event('group'); - ev.confirm = this.removeFromCache.bind(this, envelope); ev.groupDetails = groupDetails; const promise = this.dispatchAndWait(ev).catch(e => { window.log.error('error processing group', e); @@ -1147,7 +1151,6 @@ MessageReceiver.prototype.extend({ Promise.all(promises).then(() => { const ev = new Event('groupsync'); - ev.confirm = this.removeFromCache.bind(this, envelope); return this.dispatchAndWait(ev); }); });