diff --git a/src/mail.js b/src/mail.js index 8e5ba2e33..0e67638c8 100644 --- a/src/mail.js +++ b/src/mail.js @@ -687,7 +687,7 @@ function disableUserMailbox(domain, userId, callback) { if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error)); mailboxdb.del(result.username, domain, function (error) { - if (error && error.reason === UserError.NOT_FOUND) return callback(new MailError(MailError.NOT_FOUND, 'no such mailbox')); + if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new MailError(MailError.NOT_FOUND, 'no such mailbox')); if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error)); callback(null); diff --git a/src/routes/mail.js b/src/routes/mail.js index 682a57deb..ca4163668 100644 --- a/src/routes/mail.js +++ b/src/routes/mail.js @@ -157,6 +157,7 @@ function enableUserMailbox(req, res, next) { mail.enableUserMailbox(req.params.domain, req.params.userId, function (error) { if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message)); + if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpSuccess(201, {})); if (error) return next(new HttpError(500, error)); next(new HttpSuccess(201, {})); @@ -168,7 +169,7 @@ function disableUserMailbox(req, res, next) { assert.strictEqual(typeof req.params.userId, 'string'); mail.disableUserMailbox(req.params.domain, req.params.userId, function (error) { - if (error && error.reason === MailError.NOT_FOUND) return next(new HttpError(404, error.message)); + if (error && error.reason === MailError.NOT_FOUND) return next(new HttpSuccess(201, {})); if (error) return next(new HttpError(500, error)); next(new HttpSuccess(201, {}));