mail: add API to get/set banner

part of #341
This commit is contained in:
Girish Ramakrishnan
2020-08-23 14:33:58 -07:00
parent a48c08bd23
commit d752403ed6
10 changed files with 62 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ exports = module.exports = {
setCatchAllAddress,
setMailRelay,
setMailEnabled,
setBanner,
sendTestMail,
@@ -261,6 +262,20 @@ function setAliases(req, res, next) {
});
}
function setBanner(req, res, next) {
assert.strictEqual(typeof req.params.domain, 'string');
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.text !== 'string') return res.status(400).send({ message: 'text must be a string' });
if ('html' in req.body && typeof req.body.html !== 'string') return res.status(400).send({ message: 'html must be a string' });
mail.setBanner(req.params.domain, { text: req.body.text, html: req.body.html || null }, function (error) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202));
});
}
function getLists(req, res, next) {
assert.strictEqual(typeof req.params.domain, 'string');