Add views tag to middlewares too
This commit is contained in:
parent
2728810f60
commit
43e186ef44
1 changed files with 8 additions and 4 deletions
|
@ -7,18 +7,21 @@ import { body, param } from 'express-validator'
|
||||||
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
|
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
|
||||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'
|
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'
|
||||||
|
|
||||||
|
const tags = [ 'views' ]
|
||||||
|
|
||||||
export const getVideoLocalViewerValidator = [
|
export const getVideoLocalViewerValidator = [
|
||||||
param('localViewerId')
|
param('localViewerId')
|
||||||
.custom(isIdValid),
|
.custom(isIdValid),
|
||||||
|
|
||||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
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)
|
const localViewer = await LocalVideoViewerModel.loadFullById(+req.params.localViewerId)
|
||||||
if (!localViewer) {
|
if (!localViewer) {
|
||||||
return res.fail({
|
return res.fail({
|
||||||
status: HttpStatusCode.NOT_FOUND_404,
|
status: HttpStatusCode.NOT_FOUND_404,
|
||||||
message: 'Local viewer not found'
|
message: 'Local viewer not found',
|
||||||
|
tags
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ export const videoViewValidator = [
|
||||||
.isInt(),
|
.isInt(),
|
||||||
|
|
||||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
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
|
if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return
|
||||||
|
|
||||||
const video = res.locals.onlyImmutableVideo
|
const video = res.locals.onlyImmutableVideo
|
||||||
|
@ -47,7 +50,8 @@ export const videoViewValidator = [
|
||||||
return res.fail({
|
return res.fail({
|
||||||
status: HttpStatusCode.BAD_REQUEST_400,
|
status: HttpStatusCode.BAD_REQUEST_400,
|
||||||
message: `Current time ${currentTime} is invalid (video ${video.uuid} duration: ${duration})`,
|
message: `Current time ${currentTime} is invalid (video ${video.uuid} duration: ${duration})`,
|
||||||
logLevel: 'warn'
|
logLevel: 'warn',
|
||||||
|
tags
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue