add route to sync dns records
merge the mail dns route with this one as well fixes #737
This commit is contained in:
@@ -21,7 +21,8 @@ exports = module.exports = {
|
||||
renewCerts,
|
||||
getServerIp,
|
||||
getLanguages,
|
||||
syncExternalLdap
|
||||
syncExternalLdap,
|
||||
syncDnsRecords
|
||||
};
|
||||
|
||||
let assert = require('assert'),
|
||||
@@ -280,6 +281,8 @@ function prepareDashboardDomain(req, res, next) {
|
||||
}
|
||||
|
||||
function renewCerts(req, res, next) {
|
||||
if ('domain' in req.body && typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
||||
|
||||
cloudron.renewCerts({ domain: req.body.domain || null }, auditSource.fromRequest(req), function (error, taskId) {
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
@@ -291,7 +294,7 @@ function syncExternalLdap(req, res, next) {
|
||||
externalLdap.startSyncer(function (error, taskId) {
|
||||
if (error) return next(new HttpError(500, error.message));
|
||||
|
||||
next(new HttpSuccess(202, { taskId: taskId }));
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -310,3 +313,17 @@ function getLanguages(req, res, next) {
|
||||
next(new HttpSuccess(200, { languages }));
|
||||
});
|
||||
}
|
||||
|
||||
function syncDnsRecords(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if ('domain' in req.body && typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
||||
if ('type' in req.body && typeof req.body.type !== 'string') return next(new HttpError(400, 'type must be a string'));
|
||||
|
||||
cloudron.syncDnsRecords(req.body, function (error, taskId) {
|
||||
if (error && error.reason === BoxError.ACCESS_DENIED) return next(new HttpSuccess(200, { error: { reason: error.reason, message: error.message }}));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(201, { taskId }));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user