]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/bulk.ts
Refactor include checks
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / bulk.ts
index f9b0f565a9e1a19ebb3fbc9cc6afb234edb31572..9bb95f5b705263c34a97bab79b6d0647b5f3ea08 100644 (file)
@@ -1,11 +1,11 @@
 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 { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 import { 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 +22,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.'
       })
     }