X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fsort.ts;h=38184fefa0dc6e6a0a98fd38c0c375aa6a70eb08;hb=d48ff09d27d234425c3e9f091ae9072d8e6d8b7a;hp=a6f5ccb6b41c8bd5ca2e53d606045d79315fb696;hpb=792dbaf07f83fbe3f1d209cd9edf190442c7d2f3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index a6f5ccb6b..38184fefa 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts @@ -1,28 +1,39 @@ import { query } from 'express-validator/check' import * as express from 'express' - -import { checkErrors } from './utils' import { logger } from '../../helpers' import { SORTABLE_COLUMNS } from '../../initializers' +import { areValidationErrors } from './utils' // Initialize constants here for better performances const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS) +const SORTABLE_JOBS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.JOBS) const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES) const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS) +const SORTABLE_VIDEO_CHANNELS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS) +const SORTABLE_FOLLOWERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWERS) +const SORTABLE_FOLLOWING_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWING) const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) +const jobsSortValidator = checkSort(SORTABLE_JOBS_COLUMNS) const videoAbusesSortValidator = checkSort(SORTABLE_VIDEO_ABUSES_COLUMNS) const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS) const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS) +const videoChannelsSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_COLUMNS) +const followersSortValidator = checkSort(SORTABLE_FOLLOWERS_COLUMNS) +const followingSortValidator = checkSort(SORTABLE_FOLLOWING_COLUMNS) // --------------------------------------------------------------------------- export { usersSortValidator, videoAbusesSortValidator, + videoChannelsSortValidator, videosSortValidator, - blacklistSortValidator + blacklistSortValidator, + followersSortValidator, + followingSortValidator, + jobsSortValidator } // --------------------------------------------------------------------------- @@ -34,7 +45,9 @@ function checkSort (sortableColumns: string[]) { (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking sort parameters', { parameters: req.query }) - checkErrors(req, res, next) + if (areValidationErrors(req, res)) return + + return next() } ] }