From 71d4af1efc810f853e1a0d986bf758c201692594 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Jun 2021 14:09:33 +0200 Subject: Use raw SQL for most of video queries --- server/middlewares/validators/shared/videos.ts | 8 ++------ server/middlewares/validators/videos/videos.ts | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts index 1a22d6513..6131379ce 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts @@ -8,7 +8,7 @@ import { MVideoAccountLight, MVideoFormattableDetails, MVideoFullLight, - MVideoIdThumbnail, + MVideoId, MVideoImmutable, MVideoThumbnail, MVideoWithRights @@ -43,16 +43,12 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi break case 'id': - res.locals.videoId = video as MVideoIdThumbnail + res.locals.videoId = video as MVideoId break case 'only-video': res.locals.onlyVideo = video as MVideoThumbnail break - - case 'only-video-with-rights': - res.locals.onlyVideoWithRights = video as MVideoWithRights - break } return true diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index a707fd086..2bed5f181 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -4,7 +4,7 @@ import { getResumableUploadPath } from '@server/helpers/upload' import { isAbleToUploadVideo } from '@server/lib/user' import { getServerActor } from '@server/models/application/application' import { ExpressPromiseHandler } from '@server/types/express' -import { MUserAccountId, MVideoWithRights } from '@server/types/models' +import { MUserAccountId, MVideoFullLight } from '@server/types/models' import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/change-ownership/video-change-ownership-accept.model' @@ -258,7 +258,7 @@ async function checkVideoFollowConstraints (req: express.Request, res: express.R } const videosCustomGetValidator = ( - fetchType: 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes', + fetchType: 'for-api' | 'all' | 'only-video' | 'only-immutable-attributes', authenticateInQuery = false ) => { return [ @@ -273,7 +273,7 @@ const videosCustomGetValidator = ( // Controllers does not need to check video rights if (fetchType === 'only-immutable-attributes') return next() - const video = getVideoWithAttributes(res) as MVideoWithRights + const video = getVideoWithAttributes(res) as MVideoFullLight // Video private or blacklisted if (video.requiresAuth()) { -- cgit v1.2.3