diff --git a/src/cloudron.js b/src/cloudron.js index e7b1b6e17..596da22a4 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -31,6 +31,7 @@ var assert = require('assert'), domains = require('./domains.js'), DomainsError = require('./domains.js').DomainsError, df = require('@sindresorhus/df'), + eventlog = require('./eventlog.js'), fs = require('fs'), mail = require('./mail.js'), mailer = require('./mailer.js'), @@ -281,8 +282,9 @@ function prepareDashboardDomain(domain, auditSource, callback) { task.on('start', (taskId) => callback(null, taskId)); } -function setDashboardDomain(domain, callback) { +function setDashboardDomain(domain, auditSource, callback) { assert.strictEqual(typeof domain, 'string'); + assert.strictEqual(typeof auditSource, 'object'); assert.strictEqual(typeof callback, 'function'); debug(`setDashboardDomain: ${domain}`); @@ -303,6 +305,8 @@ function setDashboardDomain(domain, callback) { clients.addDefaultClients(config.adminOrigin(), function (error) { if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, error)); + eventlog.add(eventlog.ACTION_DASHBOARD_DOMAIN_UPDATE, auditSource, { domain: domain, fqdn: fqdn }); + mail.setMailFqdn(fqdn, domain, NOOP_CALLBACK); callback(null); diff --git a/src/eventlog.js b/src/eventlog.js index 3468d0dfc..5479c605c 100644 --- a/src/eventlog.js +++ b/src/eventlog.js @@ -30,6 +30,8 @@ exports = module.exports = { ACTION_CERTIFICATE_NEW: 'certificate.new', ACTION_CERTIFICATE_RENEWAL: 'certificate.renew', + ACTION_DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update', + ACTION_DOMAIN_ADD: 'domain.add', ACTION_DOMAIN_UPDATE: 'domain.update', ACTION_DOMAIN_REMOVE: 'domain.remove', diff --git a/src/mail.js b/src/mail.js index b413ed732..43df0ab99 100644 --- a/src/mail.js +++ b/src/mail.js @@ -772,7 +772,7 @@ function setDnsRecords(domain, mailFqdn, callback) { debug('setDnsRecords: %j', records); - txtRecordsWithSpf(domain, function (error, txtRecords) { + txtRecordsWithSpf(domain, mailFqdn, function (error, txtRecords) { if (error) return callback(error); if (txtRecords) records.push({ subdomain: '', domain: domain, type: 'TXT', values: txtRecords }); diff --git a/src/provision.js b/src/provision.js index e7014a32e..e66e43609 100644 --- a/src/provision.js +++ b/src/provision.js @@ -174,7 +174,7 @@ function setup(dnsConfig, autoconf, auditSource, callback) { async.series([ domains.prepareDashboardDomain.bind(null, domain, auditSource, (progress) => setProgress('setup', progress.message, NOOP_CALLBACK)), - cloudron.setDashboardDomain.bind(null, domain), // this sets up the config.fqdn() + cloudron.setDashboardDomain.bind(null, domain, auditSource), // this sets up the config.fqdn() mail.addDomain.bind(null, domain), // this relies on config.mailFqdn() setProgress.bind(null, 'setup', 'Applying auto-configuration'), autoprovision.bind(null, autoconf), diff --git a/src/routes/cloudron.js b/src/routes/cloudron.js index 85c10e595..12ea02ee2 100644 --- a/src/routes/cloudron.js +++ b/src/routes/cloudron.js @@ -154,7 +154,7 @@ function getLogStream(req, res, next) { function setDashboardDomain(req, res, next) { if (!req.body.domain || typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string')); - cloudron.setDashboardDomain(req.body.domain, function (error) { + cloudron.setDashboardDomain(req.body.domain, auditSource(req), function (error) { if (error && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message)); if (error) return next(new HttpError(500, error));