add route to enable/disable mail
mail is disabled by default Part of #16
This commit is contained in:
@@ -19,6 +19,9 @@ exports = module.exports = {
|
||||
getTimeZone: getTimeZone,
|
||||
setTimeZone: setTimeZone,
|
||||
|
||||
getMailConfig: getMailConfig,
|
||||
setMailConfig: setMailConfig,
|
||||
|
||||
getAppstoreConfig: getAppstoreConfig,
|
||||
setAppstoreConfig: setAppstoreConfig,
|
||||
|
||||
@@ -98,6 +101,27 @@ function setTimeZone(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function getMailConfig(req, res, next) {
|
||||
settings.getMailConfig(function (error, mail) {
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, mail));
|
||||
});
|
||||
}
|
||||
|
||||
function setMailConfig(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled is required'));
|
||||
|
||||
settings.setMailConfig({ enabled: req.body.enabled }, function (error) {
|
||||
if (error && error.reason === SettingsError.BAD_FIELD) return next(new HttpError(400, error.message));
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200));
|
||||
});
|
||||
}
|
||||
|
||||
function setCloudronAvatar(req, res, next) {
|
||||
assert.strictEqual(typeof req.files, 'object');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user