merge userdb.js into users.js

This commit is contained in:
Girish Ramakrishnan
2021-07-15 09:50:11 -07:00
parent 2840bba4bf
commit a1c61facdc
27 changed files with 1021 additions and 1456 deletions
+9 -28
View File
@@ -22,7 +22,6 @@ exports = module.exports = {
};
const assert = require('assert'),
async = require('async'),
auditSource = require('./auditsource.js'),
BoxError = require('./boxerror.js'),
changelog = require('./changelog.js'),
@@ -178,21 +177,12 @@ async function certificateRenewalError(eventId, vhost, errorMessage) {
assert.strictEqual(typeof vhost, 'string');
assert.strictEqual(typeof errorMessage, 'string');
return new Promise((resolve, reject) => {
users.getAdmins(function (error, admins) {
if (error) return reject(error);
await add(eventId, `Certificate renewal of ${vhost} failed`, `Failed to renew certs of ${vhost}: ${errorMessage}. Renewal will be retried in 12 hours.`);
async.eachSeries(admins, function (admin, iteratorDone) {
mailer.certificateRenewalError(admin.email, vhost, errorMessage, iteratorDone);
}, async function (error) {
if (error) return reject(error);
await add(eventId, `Certificate renewal of ${vhost} failed`, `Failed to renew certs of ${vhost}: ${errorMessage}. Renewal will be retried in 12 hours.`);
resolve();
});
});
});
const admins = await users.getAdmins();
for (const admin of admins) {
mailer.certificateRenewalError(admin.email, vhost, errorMessage);
}
}
async function backupFailed(eventId, taskId, errorMessage) {
@@ -211,19 +201,10 @@ async function backupFailed(eventId, taskId, errorMessage) {
}
if (count !== 3) return; // less than 3 failures
return new Promise((resolve, reject) => {
users.getSuperadmins(function (error, superadmins) {
if (error) return reject(error);
async.eachSeries(superadmins, function (superadmin, iteratorDone) {
mailer.backupFailed(superadmin.email, errorMessage, `${settings.dashboardOrigin()}/logs.html?taskId=${taskId}`, iteratorDone);
}, function (error) {
if (error) return reject(error);
resolve();
});
});
});
const superadmins = await users.getSuperadmins();
for (const superadmin of superadmins) {
mailer.backupFailed(superadmin.email, errorMessage, `${settings.dashboardOrigin()}/logs.html?taskId=${taskId}`);
}
}
// id is unused but nice to search code