diff --git a/src/mail.js b/src/mail.js index 963e485a7..fa4eb265b 100644 --- a/src/mail.js +++ b/src/mail.js @@ -62,6 +62,7 @@ function MailError(reason, errorOrMessage) { util.inherits(MailError, Error); MailError.INTERNAL_ERROR = 'Internal Error'; MailError.BAD_FIELD = 'Bad Field'; +MailError.NOT_FOUND = 'Not Found'; function checkOutboundPort25(callback) { assert.strictEqual(typeof callback, 'function'); @@ -463,7 +464,7 @@ function restartMail(callback) { // MAIL_DOMAIN is the domain for which this server is relaying mails // mail container uses /app/data for backed up data and /run for restart-able data - if (process.env.BOX_ENV === 'test') return callback(); + if (process.env.BOX_ENV === 'test' && !process.env.TEST_CREATE_INFRA) return callback(); function onCertificateChanged(domain) { if (domain === '*.' + config.fqdn() || domain === config.adminFqdn()) restartMail(NOOP_CALLBACK); diff --git a/src/user.js b/src/user.js index b1aec02a9..c52dc94d1 100644 --- a/src/user.js +++ b/src/user.js @@ -178,7 +178,7 @@ function createUser(username, password, email, displayName, auditSource, options if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.ALREADY_EXISTS, error.message)); if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); if (mailConfig.enabled) { @@ -259,7 +259,7 @@ function verifyWithEmail(email, password, callback) { email = email.toLowerCase(); - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); if (mailConfig.enabled) return verifyWithUsername(email.split('@')[0], password, callback); @@ -302,7 +302,7 @@ function listUsers(callback) { userdb.getAllWithGroupIds(function (error, results) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); results.forEach(function (result) { @@ -345,7 +345,7 @@ function getUser(userId, callback) { result.groupIds = groupIds; result.admin = groupIds.indexOf(constants.ADMIN_GROUP_ID) !== -1; - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); if (mailConfig.enabled) { @@ -451,7 +451,7 @@ function getAllAdmins(callback) { userdb.getAllAdmins(function (error, admins) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); admins.forEach(function (admin) { @@ -575,7 +575,7 @@ function getOwner(callback) { if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND)); if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); - mail.getMailConfig(function (error, mailConfig) { + mail.get(config.fqdn(), function (error, mailConfig) { if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error)); if (mailConfig.enabled) {