Add views tag to middlewares too
This commit is contained in:
parent
2728810f60
commit
43e186ef44
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue