Do not error if mailbox state is already correct

This commit is contained in:
Johannes Zellner
2018-01-24 15:40:32 +01:00
parent c7282e861c
commit 962ebc835d
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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);
+2 -1
View File
@@ -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, {}));