From 37a44fc915eef2140e22ceb96aba6b6eb2509007 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 17 Jun 2021 16:02:38 +0200 Subject: Add ability to search playlists --- server/middlewares/validators/search.ts | 9 +++++---- server/middlewares/validators/sort.ts | 3 +++ server/middlewares/validators/videos/video-channels.ts | 13 +++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts index e2e1c6aae..7bbf81048 100644 --- a/server/middlewares/validators/search.ts +++ b/server/middlewares/validators/search.ts @@ -49,11 +49,12 @@ const videoChannelsListSearchValidator = [ } ] -const videoChannelsOwnSearchValidator = [ - query('search').optional().not().isEmpty().withMessage('Should have a valid search'), +const videoPlaylistsListSearchValidator = [ + query('search').not().isEmpty().withMessage('Should have a valid search'), + query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking video channels search query', { parameters: req.query }) + logger.debug('Checking video playlists search query', { parameters: req.query }) if (areValidationErrors(req, res)) return @@ -66,5 +67,5 @@ const videoChannelsOwnSearchValidator = [ export { videosSearchValidator, videoChannelsListSearchValidator, - videoChannelsOwnSearchValidator + videoPlaylistsListSearchValidator } diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts index d67b6f3ba..473010460 100644 --- a/server/middlewares/validators/sort.ts +++ b/server/middlewares/validators/sort.ts @@ -9,6 +9,7 @@ const SORTABLE_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.ABUSES) const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS) const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH) const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH) +const SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS_SEARCH) const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS) const SORTABLE_VIDEO_COMMENTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS) const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS) @@ -34,6 +35,7 @@ const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS) const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS) const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS) const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS) +const videoPlaylistsSearchSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_SEARCH_COLUMNS) const videoCommentsValidator = checkSort(SORTABLE_VIDEO_COMMENTS_COLUMNS) const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS) const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS) @@ -75,5 +77,6 @@ export { userNotificationsSortValidator, videoPlaylistsSortValidator, videoRedundanciesSortValidator, + videoPlaylistsSearchSortValidator, pluginsSortValidator } diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index 911a25bfb..e7df185e4 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts @@ -141,6 +141,18 @@ const videoChannelStatsValidator = [ } ] +const videoChannelsListValidator = [ + query('search').optional().not().isEmpty().withMessage('Should have a valid search'), + + (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking video channels search query', { parameters: req.query }) + + if (areValidationErrors(req, res)) return + + return next() + } +] + // --------------------------------------------------------------------------- export { @@ -148,6 +160,7 @@ export { videoChannelsUpdateValidator, videoChannelsRemoveValidator, videoChannelsNameWithHostValidator, + videoChannelsListValidator, localVideoChannelValidator, videoChannelStatsValidator } -- cgit v1.2.3