mail: restart apps using email addon

move this logic from frontend to backend
This commit is contained in:
Girish Ramakrishnan
2025-03-10 21:14:55 +01:00
parent 72635c8711
commit 8a51582d8a
3 changed files with 18 additions and 3 deletions

View File

@@ -114,6 +114,9 @@ async function setMailEnabled(req, res, next) {
if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled is required'));
// can take a while to restart the mail container
req.clearTimeout();
const [error] = await safe(mail.setMailEnabled(req.params.domain, !!req.body.enabled, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
@@ -237,7 +240,7 @@ async function setAliases(req, res, next) {
if (!Array.isArray(req.body.aliases)) return next(new HttpError(400, 'aliases must be an array'));
for (let alias of req.body.aliases) {
for (const alias of req.body.aliases) {
if (!alias || typeof alias !== 'object') return next(new HttpError(400, 'each alias must have a name and domain'));
if (typeof alias.name !== 'string') return next(new HttpError(400, 'name must be a string'));
if (typeof alias.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));