From ca4b4b2e5590c1b37cff1fe1be7f797b93351229 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Jun 2021 09:57:19 +0200 Subject: Fetch directly all video attributes for get API --- server/middlewares/validators/shared/videos.ts | 5 +++++ server/middlewares/validators/videos/videos.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts index 3134f623d..1a22d6513 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts @@ -6,6 +6,7 @@ import { MUser, MUserAccountId, MVideoAccountLight, + MVideoFormattableDetails, MVideoFullLight, MVideoIdThumbnail, MVideoImmutable, @@ -29,6 +30,10 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi } switch (fetchType) { + case 'for-api': + res.locals.videoAPI = video as MVideoFormattableDetails + break + case 'all': res.locals.videoAll = video as MVideoFullLight break diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 7f278c9f6..a707fd086 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -258,7 +258,7 @@ async function checkVideoFollowConstraints (req: express.Request, res: express.R } const videosCustomGetValidator = ( - fetchType: 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes', + fetchType: 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes', authenticateInQuery = false ) => { return [ -- cgit v1.2.3