MessageReceiver: Remove contact/group sync from cache immediately

This commit is contained in:
Scott Nonnenberg 2019-10-04 10:30:43 -07:00
parent 0f93c780ec
commit 28aed8247f
2 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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);
});
});