split mail and mailserver
mail = all the per-domain code mailserver = all the mail server level code
This commit is contained in:
@@ -15,7 +15,7 @@ const assert = require('assert'),
|
||||
debug = require('debug')('box:routes/mailserver'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
mail = require('../mail.js'),
|
||||
mailServer = require('../mailserver.js'),
|
||||
middleware = require('../middleware/index.js'),
|
||||
safe = require('safetydance'),
|
||||
services = require('../services.js'),
|
||||
@@ -23,7 +23,7 @@ const assert = require('assert'),
|
||||
|
||||
// because of how the proxy middleware works, the http response is already sent by the time this function is called
|
||||
async function restart(req, res, next) {
|
||||
await safe(mail.restartMail(), { debug });
|
||||
await safe(mailServer.restartMail(), { debug });
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ async function queueProxy(req, res, next) {
|
||||
}
|
||||
|
||||
async function getLocation(req, res, next) {
|
||||
const [error, result] = await safe(mail.getLocation());
|
||||
const [error, result] = await safe(mailServer.getLocation());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { domain: result.domain, subdomain: result.subdomain }));
|
||||
@@ -78,7 +78,7 @@ async function setLocation(req, res, next) {
|
||||
if (typeof req.body.domain !== 'string') return next(new HttpError(400, 'domain must be a string'));
|
||||
if (typeof req.body.subdomain !== 'string') return next(new HttpError(400, 'subdomain must be a string'));
|
||||
|
||||
const [error, taskId] = await safe(mail.setLocation(req.body.subdomain, req.body.domain, AuditSource.fromRequest(req)));
|
||||
const [error, taskId] = await safe(mailServer.setLocation(req.body.subdomain, req.body.domain, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
|
||||
Reference in New Issue
Block a user