X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fbulk.ts;h=6fec5814930e6a3ab5ee3bde1b9b025de1ba4e44;hb=171efc48e67498406feb6d7873b3482b41505515;hp=f9b0f565a9e1a19ebb3fbc9cc6afb234edb31572;hpb=444c0a0e017824fb4ce526281a22c4abe0a13c50;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts index f9b0f565a..6fec58149 100644 --- a/server/middlewares/validators/bulk.ts +++ b/server/middlewares/validators/bulk.ts @@ -1,11 +1,10 @@ import * as express from 'express' import { body } from 'express-validator' import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' -import { doesAccountNameWithHostExist } from '@server/helpers/middlewares' -import { UserRight } from '@shared/models' +import { HttpStatusCode, UserRight } from '@shared/models' import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' +import { areValidationErrors, doesAccountNameWithHostExist } from './shared' const bulkRemoveCommentsOfValidator = [ body('accountName').exists().withMessage('Should have an account name with host'), @@ -22,9 +21,9 @@ const bulkRemoveCommentsOfValidator = [ const body = req.body as BulkRemoveCommentsOfBody if (body.scope === 'instance' && user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) !== true) { - return res.status(403) - .json({ - error: 'User cannot remove any comments of this instance.' + return res.fail({ + status: HttpStatusCode.FORBIDDEN_403, + message: 'User cannot remove any comments of this instance.' }) }