return 409 when an email domain conflict is found

This commit is contained in:
Johannes Zellner
2018-01-29 17:17:47 +01:00
parent ec7b550ca6
commit 6115b1cecf

View File

@@ -53,7 +53,7 @@ function add(req, res, next) {
mail.add(req.body.domain, 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 HttpError(400, error.message));
if (error && error.reason === MailError.ALREADY_EXISTS) return next(new HttpError(409, 'domain already exists'));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(201, { domain: req.body.domain }));