From 61b909b9bf849516f30dab2bf5977acfbbddc5c6 Mon Sep 17 00:00:00 2001 From: PhieF Date: Wed, 27 Jun 2018 14:24:49 +0200 Subject: Filter by category (#720) * get videos with specific category (api) * update api doc with category * add url parameter to filter by category * fix lint issues --- server/controllers/api/videos/index.ts | 1 + server/models/video/video.ts | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'server') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index ca800a9a8..b4ced8c1e 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -407,6 +407,7 @@ async function listVideos (req: express.Request, res: express.Response, next: ex start: req.query.start, count: req.query.count, sort: req.query.sort, + category: req.query.category, hideNSFW: isNSFWHidden(res), filter: req.query.filter as VideoFilter, withFiles: false diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 0041e4d38..0af70cadf 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -106,6 +106,7 @@ export enum ScopeNames { actorId: number, hideNSFW: boolean, filter?: VideoFilter, + category?: number, withFiles?: boolean, accountId?: number, videoChannelId?: number @@ -215,6 +216,10 @@ export enum ScopeNames { query.where['nsfw'] = false } + if (options.category) { + query.where['category'] = options.category + } + if (options.accountId) { accountInclude.where = { id: options.accountId @@ -730,6 +735,7 @@ export class VideoModel extends Model { sort: string, hideNSFW: boolean, withFiles: boolean, + category?: number, filter?: VideoFilter, accountId?: number, videoChannelId?: number @@ -746,6 +752,7 @@ export class VideoModel extends Model { ScopeNames.AVAILABLE_FOR_LIST, { actorId: serverActor.id, hideNSFW: options.hideNSFW, + category: options.category, filter: options.filter, withFiles: options.withFiles, accountId: options.accountId, -- cgit v1.2.3