X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fsort.ts;h=7d063910799f419d607724e7420a14040b8716b5;hb=9972ace3a3bc65865fb3aaaa865a400386e49252;hp=c9978e3b4542b71e1a027240068216c1cc5f333a;hpb=6c1da7937cedbc1d4013cff0686d785247229c52;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index c9978e3b4..7d0639107 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts @@ -1,6 +1,6 @@ import express from 'express' import { query } from 'express-validator' -import { logger } from '@server/helpers/logger' + import { SORTABLE_COLUMNS } from '../../initializers/constants' import { areValidationErrors } from './shared' @@ -10,12 +10,12 @@ function checkSortFactory (columns: string[], tags: string[] = []) { function checkSort (sortableColumns: string[], tags: string[] = []) { return [ - query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'), + query('sort') + .optional() + .isIn(sortableColumns), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking sort parameters', { parameters: req.query, tags }) - - if (areValidationErrors(req, res)) return + if (areValidationErrors(req, res, { tags })) return return next() } @@ -52,6 +52,7 @@ const videoPlaylistsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_PLAY const pluginsSortValidator = checkSortFactory(SORTABLE_COLUMNS.PLUGINS) const availablePluginsSortValidator = checkSortFactory(SORTABLE_COLUMNS.AVAILABLE_PLUGINS) const videoRedundanciesSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_REDUNDANCIES) +const videoChannelSyncsSortValidator = checkSortFactory(SORTABLE_COLUMNS.VIDEO_CHANNEL_SYNCS) const accountsFollowersSortValidator = checkSortFactory(SORTABLE_COLUMNS.ACCOUNT_FOLLOWERS) const videoChannelsFollowersSortValidator = checkSortFactory(SORTABLE_COLUMNS.CHANNEL_FOLLOWERS) @@ -84,5 +85,6 @@ export { videoPlaylistsSearchSortValidator, accountsFollowersSortValidator, videoChannelsFollowersSortValidator, + videoChannelSyncsSortValidator, pluginsSortValidator }