From 55c3d9371e19c8fabf7dfb06dec57c32455e7c6d Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 13 Nov 2018 09:44:30 -0800 Subject: [PATCH] Bump sender certificate timer after registration for re-link --- js/modules/refresh_sender_certificate.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/modules/refresh_sender_certificate.js b/js/modules/refresh_sender_certificate.js index a25f10d3e..83acef60d 100644 --- a/js/modules/refresh_sender_certificate.js +++ b/js/modules/refresh_sender_certificate.js @@ -7,9 +7,9 @@ module.exports = { const ONE_DAY = 24 * 60 * 60 * 1000; // one day const MINIMUM_TIME_LEFT = 2 * 60 * 60 * 1000; // two hours -let initialized = false; let timeout = null; let scheduledTime = null; +let scheduleNext = null; // We need to refresh our own profile regularly to account for newly-added devices which // do not support unidentified delivery. @@ -20,11 +20,12 @@ function refreshOurProfile() { } function initialize({ events, storage, navigator, logger }) { - if (initialized) { - logger.warn('refreshSenderCertificate: already initialized!'); + // We don't want to set up all of the below functions, but we do want to ensure that our + // refresh timer is up-to-date. + if (scheduleNext) { + scheduleNext(); return; } - initialized = true; runWhenOnline(); @@ -55,6 +56,9 @@ function initialize({ events, storage, navigator, logger }) { setTimeoutForNextRun(time); } + // Keeping this entrypoint around so more inialize() calls just kick the timing + scheduleNext = scheduleNextRotation; + async function run() { logger.info('refreshSenderCertificate: Getting new certificate...'); try {