certs: fix renewal notification

This commit is contained in:
Girish Ramakrishnan
2021-06-24 00:54:28 -07:00
parent 2b13593630
commit b24cf78bc0
3 changed files with 19 additions and 11 deletions
+14 -7
View File
@@ -22,6 +22,7 @@ exports = module.exports = {
};
const assert = require('assert'),
async = require('async'),
auditSource = require('./auditsource.js'),
BoxError = require('./boxerror.js'),
changelog = require('./changelog.js'),
@@ -178,15 +179,21 @@ async function certificateRenewalError(eventId, vhost, errorMessage) {
assert.strictEqual(typeof vhost, 'string');
assert.strictEqual(typeof errorMessage, 'string');
const getAdmins = util.callbackify(users.getAdmins);
return new Promise((resolve, reject) => {
users.getAdmins(function (error, admins) {
if (error) return reject(error);
const admins = await getAdmins();
async.eachSeries(admins, function (admin, iteratorDone) {
mailer.certificateRenewalError(admin.email, vhost, errorMessage, iteratorDone);
}, async function (error) {
if (error) return reject(error);
for (const admin of admins) {
mailer.certificateRenewalError(admin.email, vhost, errorMessage);
}
await add(eventId, `Certificate renewal of ${vhost} failed`, `Failed to renew certs of ${vhost}: ${errorMessage}. Renewal will be retried in 12 hours.`);
await add(eventId, `Certificate renewal of ${vhost} failed`, `Failed to renew certs of ${vhost}: ${errorMessage}. Renewal will be retried in 12 hours`);
resolve();
});
});
});
}
async function backupFailed(eventId, taskId, errorMessage) {
@@ -205,7 +212,7 @@ async function backupFailed(eventId, taskId, errorMessage) {
}
if (count !== 3) return; // less than 3 failures
const getSuperAdmins = util.callbackify(users.getSuperAdmins);
const getSuperAdmins = util.promisify(users.getSuperAdmins);
const superAdmins = await getSuperAdmins();