Add event to track dashboard update

This commit is contained in:
Girish Ramakrishnan
2019-02-04 20:24:28 -08:00
parent 9f5471ee85
commit 7e6ce1a1ef
5 changed files with 10 additions and 4 deletions
+5 -1
View File
@@ -31,6 +31,7 @@ var assert = require('assert'),
domains = require('./domains.js'), domains = require('./domains.js'),
DomainsError = require('./domains.js').DomainsError, DomainsError = require('./domains.js').DomainsError,
df = require('@sindresorhus/df'), df = require('@sindresorhus/df'),
eventlog = require('./eventlog.js'),
fs = require('fs'), fs = require('fs'),
mail = require('./mail.js'), mail = require('./mail.js'),
mailer = require('./mailer.js'), mailer = require('./mailer.js'),
@@ -281,8 +282,9 @@ function prepareDashboardDomain(domain, auditSource, callback) {
task.on('start', (taskId) => callback(null, taskId)); task.on('start', (taskId) => callback(null, taskId));
} }
function setDashboardDomain(domain, callback) { function setDashboardDomain(domain, auditSource, callback) {
assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function'); assert.strictEqual(typeof callback, 'function');
debug(`setDashboardDomain: ${domain}`); debug(`setDashboardDomain: ${domain}`);
@@ -303,6 +305,8 @@ function setDashboardDomain(domain, callback) {
clients.addDefaultClients(config.adminOrigin(), function (error) { clients.addDefaultClients(config.adminOrigin(), function (error) {
if (error) return callback(new CloudronError(CloudronError.INTERNAL_ERROR, 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); mail.setMailFqdn(fqdn, domain, NOOP_CALLBACK);
callback(null); callback(null);
+2
View File
@@ -30,6 +30,8 @@ exports = module.exports = {
ACTION_CERTIFICATE_NEW: 'certificate.new', ACTION_CERTIFICATE_NEW: 'certificate.new',
ACTION_CERTIFICATE_RENEWAL: 'certificate.renew', ACTION_CERTIFICATE_RENEWAL: 'certificate.renew',
ACTION_DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update',
ACTION_DOMAIN_ADD: 'domain.add', ACTION_DOMAIN_ADD: 'domain.add',
ACTION_DOMAIN_UPDATE: 'domain.update', ACTION_DOMAIN_UPDATE: 'domain.update',
ACTION_DOMAIN_REMOVE: 'domain.remove', ACTION_DOMAIN_REMOVE: 'domain.remove',
+1 -1
View File
@@ -772,7 +772,7 @@ function setDnsRecords(domain, mailFqdn, callback) {
debug('setDnsRecords: %j', records); debug('setDnsRecords: %j', records);
txtRecordsWithSpf(domain, function (error, txtRecords) { txtRecordsWithSpf(domain, mailFqdn, function (error, txtRecords) {
if (error) return callback(error); if (error) return callback(error);
if (txtRecords) records.push({ subdomain: '', domain: domain, type: 'TXT', values: txtRecords }); if (txtRecords) records.push({ subdomain: '', domain: domain, type: 'TXT', values: txtRecords });
+1 -1
View File
@@ -174,7 +174,7 @@ function setup(dnsConfig, autoconf, auditSource, callback) {
async.series([ async.series([
domains.prepareDashboardDomain.bind(null, domain, auditSource, (progress) => setProgress('setup', progress.message, NOOP_CALLBACK)), 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() mail.addDomain.bind(null, domain), // this relies on config.mailFqdn()
setProgress.bind(null, 'setup', 'Applying auto-configuration'), setProgress.bind(null, 'setup', 'Applying auto-configuration'),
autoprovision.bind(null, autoconf), autoprovision.bind(null, autoconf),
+1 -1
View File
@@ -154,7 +154,7 @@ function getLogStream(req, res, next) {
function setDashboardDomain(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')); 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 && error.reason === CloudronError.BAD_FIELD) return next(new HttpError(404, error.message));
if (error) return next(new HttpError(500, error)); if (error) return next(new HttpError(500, error));