move dashboard setting into dashboard.js

This commit is contained in:
Girish Ramakrishnan
2023-08-11 19:41:05 +05:30
parent 27ce8f9351
commit eee49a8291
25 changed files with 157 additions and 156 deletions

View File

@@ -160,6 +160,7 @@ const appstore = require('./appstore.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
CronJob = require('cron').CronJob,
dashboard = require('./dashboard.js'),
database = require('./database.js'),
debug = require('debug')('box:apps'),
dns = require('./dns.js'),
@@ -181,7 +182,6 @@ const appstore = require('./appstore.js'),
safe = require('safetydance'),
semver = require('semver'),
services = require('./services.js'),
settings = require('./settings.js'),
shell = require('./shell.js'),
storage = require('./storage.js'),
system = require('./system.js'),
@@ -1270,6 +1270,7 @@ async function validateLocations(locations) {
constants.IMAP_SUBDOMAIN
];
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
for (const location of locations) {
if (!(location.domain in domainObjectMap)) return new BoxError(BoxError.BAD_FIELD, `No such domain in ${location.type} location`);
@@ -1281,7 +1282,7 @@ async function validateLocations(locations) {
if (RESERVED_SUBDOMAINS.indexOf(subdomain) !== -1) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved`);
if (dns.fqdn(subdomain, location.domain) === settings.dashboardFqdn()) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved`);
if (dns.fqdn(subdomain, location.domain) === dashboardFqdn) return new BoxError(BoxError.BAD_FIELD, `subdomain '${subdomain}' is reserved for dashboard`);
const error = dns.validateHostname(subdomain, location.domain);
if (error) return new BoxError(BoxError.BAD_FIELD, `Bad ${location.type} location: ${error.message}`);