1 import express from 'express'
2 import { body } from 'express-validator'
3 import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
4 import { HttpStatusCode, UserRight } from '@shared/models'
5 import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
6 import { logger } from '../../helpers/logger'
7 import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
9 const bulkRemoveCommentsOfValidator = [
13 .custom(isBulkRemoveCommentsOfScopeValid),
15 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body })
18 if (areValidationErrors(req, res)) return
19 if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
21 const user = res.locals.oauth.token.User
22 const body = req.body as BulkRemoveCommentsOfBody
24 if (body.scope === 'instance' && user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) !== true) {
26 status: HttpStatusCode.FORBIDDEN_403,
27 message: 'User cannot remove any comments of this instance.'
35 // ---------------------------------------------------------------------------
38 bulkRemoveCommentsOfValidator
41 // ---------------------------------------------------------------------------