store subdomain in database instead of fqdn
this makes it more consistent with the locations table
This commit is contained in:
@@ -251,13 +251,12 @@ async function checkCertificate() {
|
||||
|
||||
async function getLocation() {
|
||||
const domain = await settings.get(settings.MAIL_DOMAIN_KEY);
|
||||
const fqdn = await settings.get(settings.MAIL_FQDN_KEY);
|
||||
const subdomain = await settings.get(settings.MAIL_SUBDOMAIN_KEY);
|
||||
|
||||
if (!domain || !fqdn) return {};
|
||||
if (!domain || !subdomain) return {};
|
||||
|
||||
const subdomain = fqdn.substr(0, fqdn.length - domain.length - 1);
|
||||
|
||||
return { domain, fqdn, subdomain };
|
||||
const fqdn = dns.fqdn(subdomain, domain);
|
||||
return { subdomain, domain, fqdn };
|
||||
}
|
||||
|
||||
async function changeLocation(auditSource, progressCallback) {
|
||||
@@ -289,12 +288,12 @@ async function changeLocation(auditSource, progressCallback) {
|
||||
await restartIfActivated();
|
||||
}
|
||||
|
||||
async function setLocation(mailDomain, mailFqdn) {
|
||||
assert.strictEqual(typeof mailDomain, 'string');
|
||||
assert.strictEqual(typeof mailFqdn, 'string');
|
||||
async function setLocation(subdomain, domain) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
|
||||
await settings.set(settings.MAIL_DOMAIN_KEY, mailDomain);
|
||||
await settings.set(settings.MAIL_FQDN_KEY, mailFqdn);
|
||||
await settings.set(settings.MAIL_SUBDOMAIN_KEY, subdomain);
|
||||
await settings.set(settings.MAIL_DOMAIN_KEY, domain);
|
||||
}
|
||||
|
||||
async function startChangeLocation(subdomain, domain, auditSource) {
|
||||
@@ -307,9 +306,7 @@ async function startChangeLocation(subdomain, domain, auditSource) {
|
||||
const error = dns.validateHostname(subdomain, domain);
|
||||
if (error) throw new BoxError(BoxError.BAD_FIELD, `Bad mail location: ${error.message}`);
|
||||
|
||||
const fqdn = dns.fqdn(subdomain, domain);
|
||||
|
||||
await setLocation(domain, fqdn);
|
||||
await setLocation(subdomain, domain);
|
||||
|
||||
const taskId = await tasks.add(tasks.TASK_CHANGE_MAIL_LOCATION, [ auditSource ]);
|
||||
tasks.startTask(taskId, {});
|
||||
|
||||
Reference in New Issue
Block a user