Skip to content

Commit

Permalink
Handle contact: don't exit early if timer is 'invalid'
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Aug 15, 2018
1 parent 621883a commit 0eb2c95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
24 changes: 10 additions & 14 deletions js/background.js
Expand Up @@ -860,20 +860,18 @@
);
const { expireTimer } = details;
const isValidExpireTimer = typeof expireTimer === 'number';
if (!isValidExpireTimer) {
return;
if (isValidExpireTimer) {
const source = textsecure.storage.user.getNumber();
const receivedAt = Date.now();

await conversation.updateExpirationTimer(
expireTimer,
source,
receivedAt,
{ fromSync: true }
);
}

const source = textsecure.storage.user.getNumber();
const receivedAt = Date.now();

await conversation.updateExpirationTimer(
expireTimer,
source,
receivedAt,
{ fromSync: true }
);

if (details.verified) {
const { verified } = details;
const verifiedEvent = new Event('verified');
Expand All @@ -885,8 +883,6 @@
verifiedEvent.viaContactSync = true;
await onVerified(verifiedEvent);
}

ev.confirm();
} catch (error) {
window.log.error('onContactReceived error:', Errors.toLogFormat(error));
}
Expand Down
7 changes: 4 additions & 3 deletions libtextsecure/message_receiver.js
Expand Up @@ -814,18 +814,19 @@ MessageReceiver.prototype.extend({
let contactDetails = contactBuffer.next();
while (contactDetails !== undefined) {
const ev = new Event('contact');
ev.confirm = this.removeFromCache.bind(this, envelope);
ev.contactDetails = contactDetails;
results.push(this.dispatchAndWait(ev));

contactDetails = contactBuffer.next();
}

const ev = new Event('contactsync');
ev.confirm = this.removeFromCache.bind(this, envelope);
results.push(this.dispatchAndWait(ev));

return Promise.all(results);
return Promise.all(results).then(() => {
window.log.info('handleContacts: finished');
return this.removeFromCache(envelope);
});
});
},
handleGroups(envelope, groups) {
Expand Down

0 comments on commit 0eb2c95

Please sign in to comment.