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

View File

@@ -750,26 +750,20 @@ function restartMail(callback) {
});
}
function restartMailIfActivated(callback) {
assert.strictEqual(typeof callback, 'function');
async function restartMailIfActivated() {
const activated = await users.isActivated();
users.isActivated(function (error, activated) {
if (error) return callback(error);
if (!activated) {
debug('restartMailIfActivated: skipping restart of mail container since Cloudron is not activated yet');
return; // not provisioned yet, do not restart container after dns setup
}
if (!activated) {
debug('restartMailIfActivated: skipping restart of mail container since Cloudron is not activated yet');
return callback(); // not provisioned yet, do not restart container after dns setup
}
restartMail(callback);
});
await util.promisify(restartMail)();
}
function handleCertChanged(callback) {
assert.strictEqual(typeof callback, 'function');
async function handleCertChanged() {
debug('handleCertChanged: will restart if activated');
restartMailIfActivated(callback);
await restartMailIfActivated();
}
async function getDomain(domain) {
@@ -998,12 +992,13 @@ function changeLocation(auditSource, progressCallback, callback) {
progressCallback({ percent: progress, message: `Updated DNS of ${domainObject.domain}: ${error ? error.message : 'success'}` });
iteratorDone();
});
}, function (error) {
}, async function (error) {
if (error) return callback(error);
progressCallback({ percent: 90, message: 'Restarting mail server' });
restartMailIfActivated(callback);
[error] = await safe(restartMailIfActivated());
callback(error);
});
});
});