Add views tag to middlewares too

This commit is contained in:
Chocobozzz 2024-06-27 10:51:36 +02:00
parent 2728810f60
commit 43e186ef44
No known key found for this signature in database
GPG Key ID: 583A612D890159BE

View File

@ -7,18 +7,21 @@ import { body, param } from 'express-validator'
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'
const tags = [ 'views' ]
export const getVideoLocalViewerValidator = [
param('localViewerId')
.custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (areValidationErrors(req, res, { tags })) return
const localViewer = await LocalVideoViewerModel.loadFullById(+req.params.localViewerId)
if (!localViewer) {
return res.fail({
status: HttpStatusCode.NOT_FOUND_404,
message: 'Local viewer not found'
message: 'Local viewer not found',
tags
})
}
@ -36,7 +39,7 @@ export const videoViewValidator = [
.isInt(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (areValidationErrors(req, res, { tags })) return
if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return
const video = res.locals.onlyImmutableVideo
@ -47,7 +50,8 @@ export const videoViewValidator = [
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
message: `Current time ${currentTime} is invalid (video ${video.uuid} duration: ${duration})`,
logLevel: 'warn'
logLevel: 'warn',
tags
})
}