diff --git a/src/apps.js b/src/apps.js index 75229cd2f..de497c345 100644 --- a/src/apps.js +++ b/src/apps.js @@ -839,7 +839,9 @@ function install(data, user, auditSource, callback) { if (error) return callback(error); const newApp = _.extend({}, data, { appStoreId, manifest, location, domain, portBindings }); - postProcess(newApp, domainObjectMap); + newApp.fqdn = domains.fqdn(newApp.location, domainObjectMap[newApp.domain]); + newApp.alternateDomains.forEach(function (ad) { ad.fqdn = domains.fqdn(ad.subdomain, domainObjectMap[ad.domain]); }); + eventlog.add(eventlog.ACTION_APP_INSTALL, auditSource, { appId: appId, app: newApp, taskId: result.taskId }); callback(null, { id : appId, taskId: result.taskId }); @@ -1173,14 +1175,13 @@ function setLocation(appId, data, auditSource, callback) { if (error) return callback(error); let values = { + location: data.location.toLowerCase(), + domain: data.domain.toLowerCase(), // these are intentionally reset, if not set portBindings: null, alternateDomains: [] }; - values.location = data.location.toLowerCase(); - values.domain = data.domain.toLowerCase(); - if ('portBindings' in data) { error = validatePortBindings(data.portBindings, app.manifest); if (error) return callback(error); @@ -1211,7 +1212,10 @@ function setLocation(appId, data, auditSource, callback) { if (error && error.reason === AppsError.ALREADY_EXISTS) error = getDuplicateErrorDetails(error.message, locations, domainObjectMap, data.portBindings); if (error) return callback(error); - eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: appId, app: app, location: values.location, domain: values.domain, portBindings: values.portBindings, alternateDomains: values.alternateDomains, taskId: result.taskId }); + values.fqdn = domains.fqdn(values.location, domainObjectMap[values.domain]); + values.alternateDomains.forEach(function (ad) { ad.fqdn = domains.fqdn(ad.subdomain, domainObjectMap[ad.domain]); }); + + eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, _.extend({ appId, app, taskId: result.taskId }, values)); callback(null, { taskId: result.taskId }); }); @@ -1538,7 +1542,7 @@ function clone(appId, data, user, auditSource, callback) { mailboxName = mailboxNameForLocation(location, manifest); } - const locations = [{location, domain}]; + const locations = [{subdomain: location, domain}]; validateLocations(locations, function (error, domainObjectMap) { if (error) return callback(error); @@ -1553,7 +1557,8 @@ function clone(appId, data, user, auditSource, callback) { mailboxName: mailboxName, enableBackup: app.enableBackup, robotsTxt: app.robotsTxt, - env: app.env + env: app.env, + alternateDomains: [] }; appdb.add(newAppId, appStoreId, manifest, location, domain, translatePortBindings(portBindings, manifest), data, function (error) { @@ -1573,7 +1578,8 @@ function clone(appId, data, user, auditSource, callback) { if (error) return callback(error); const newApp = _.extend({}, data, { appStoreId, manifest, location, domain, portBindings }); - postProcess(newApp, domainObjectMap); + newApp.fqdn = domains.fqdn(newApp.location, domainObjectMap[newApp.domain]); + newApp.alternateDomains.forEach(function (ad) { ad.fqdn = domains.fqdn(ad.subdomain, domainObjectMap[ad.domain]); }); eventlog.add(eventlog.ACTION_APP_CLONE, auditSource, { appId: newAppId, oldAppId: appId, backupId: backupId, oldApp: app, newApp: newApp, taskId: result.taskId }); callback(null, { id: newAppId, taskId: result.taskId });