diff --git a/src/eventlog.js b/src/eventlog.js index 70ccb8d08..6b62fcff1 100644 --- a/src/eventlog.js +++ b/src/eventlog.js @@ -25,9 +25,9 @@ exports = module.exports = { ACTION_CERTIFICATE_RENEWAL: 'certificate.renew', + ACTION_MAIL_ENABLED: 'mail.enabled', ACTION_MAIL_MAILBOX_ADD: 'mail.box.add', ACTION_MAIL_MAILBOX_REMOVE: 'mail.box.remove', - ACTION_MAIL_LIST_ADD: 'mail.list.add', ACTION_MAIL_LIST_REMOVE: 'mail.list.remove', diff --git a/src/mail.js b/src/mail.js index 10ab57da1..ed4b61c64 100644 --- a/src/mail.js +++ b/src/mail.js @@ -853,9 +853,10 @@ function setMailRelay(domain, relay, callback) { }); } -function setMailEnabled(domain, enabled, callback) { +function setMailEnabled(domain, enabled, auditSource, callback) { assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof enabled, 'boolean'); + assert.strictEqual(typeof auditSource, 'object'); assert.strictEqual(typeof callback, 'function'); maildb.update(domain, { enabled: enabled }, function (error) { @@ -864,6 +865,8 @@ function setMailEnabled(domain, enabled, callback) { restartMail(NOOP_CALLBACK); + eventlog.add(eventlog.ACTION_MAIL_ENABLED, auditSource, { domain, enabled }); + callback(null); }); } diff --git a/src/routes/mail.js b/src/routes/mail.js index d22752b15..bef1d9018 100644 --- a/src/routes/mail.js +++ b/src/routes/mail.js @@ -186,7 +186,7 @@ function setMailEnabled(req, res, next) { if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled is required')); - mail.setMailEnabled(req.params.domain, !!req.body.enabled, function (error) { + mail.setMailEnabled(req.params.domain, !!req.body.enabled, auditSource(req), function (error) { if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message)); if (error && error.reason === MailError.BAD_FIELD) return next(new HttpError(400, error.message)); if (error && error.reason === MailError.BILLING_REQUIRED) return next(new HttpError(402, error.message));