From 2760b454a761f6af3138b2fb5f34340772ab0d1e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Oct 2021 14:37:04 +0200 Subject: Deprecate filter video query Introduce include and isLocal instead --- server/helpers/custom-validators/videos.ts | 6 ++++++ server/helpers/query.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index c3604fbad..1d56ade6f 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -2,6 +2,7 @@ import { UploadFilesForCheck } from 'express' import { values } from 'lodash' import magnetUtil from 'magnet-uri' import validator from 'validator' +import { VideoInclude } from '@shared/models' import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' import { CONSTRAINTS_FIELDS, @@ -21,6 +22,10 @@ function isVideoFilterValid (filter: VideoFilter) { return filter === 'local' || filter === 'all-local' || filter === 'all' } +function isVideoIncludeValid (include: VideoInclude) { + return exists(include) && validator.isInt('' + include) +} + function isVideoCategoryValid (value: any) { return value === null || VIDEO_CATEGORIES[value] !== undefined } @@ -146,6 +151,7 @@ export { isVideoOriginallyPublishedAtValid, isVideoMagnetUriValid, isVideoStateValid, + isVideoIncludeValid, isVideoViewsValid, isVideoRatingTypeValid, isVideoFileExtnameValid, diff --git a/server/helpers/query.ts b/server/helpers/query.ts index e711b15f2..79cf076d1 100644 --- a/server/helpers/query.ts +++ b/server/helpers/query.ts @@ -18,8 +18,10 @@ function pickCommonVideoQuery (query: VideosCommonQueryAfterSanitize) { 'languageOneOf', 'tagsOneOf', 'tagsAllOf', - 'filter', - 'skipCount' + 'isLocal', + 'include', + 'skipCount', + 'search' ]) } @@ -29,7 +31,6 @@ function pickSearchVideoQuery (query: VideosSearchQueryAfterSanitize) { ...pick(query, [ 'searchTarget', - 'search', 'host', 'startDate', 'endDate', -- cgit v1.2.3