diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:09:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-11 14:09:52 +0200 |
commit | 71d4af1efc810f853e1a0d986bf758c201692594 (patch) | |
tree | 2066053638baefb6430772c2e0a0aa1774019a51 /server/middlewares/validators | |
parent | 3c79c2ce86eaf9e151ab6c2c9d1f646968a16744 (diff) | |
download | PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.tar.gz PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.tar.zst PeerTube-71d4af1efc810f853e1a0d986bf758c201692594.zip |
Use raw SQL for most of video queries
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/shared/videos.ts | 8 | ||||
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 6 |
2 files changed, 5 insertions, 9 deletions
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 { | |||
8 | MVideoAccountLight, | 8 | MVideoAccountLight, |
9 | MVideoFormattableDetails, | 9 | MVideoFormattableDetails, |
10 | MVideoFullLight, | 10 | MVideoFullLight, |
11 | MVideoIdThumbnail, | 11 | MVideoId, |
12 | MVideoImmutable, | 12 | MVideoImmutable, |
13 | MVideoThumbnail, | 13 | MVideoThumbnail, |
14 | MVideoWithRights | 14 | MVideoWithRights |
@@ -43,16 +43,12 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi | |||
43 | break | 43 | break |
44 | 44 | ||
45 | case 'id': | 45 | case 'id': |
46 | res.locals.videoId = video as MVideoIdThumbnail | 46 | res.locals.videoId = video as MVideoId |
47 | break | 47 | break |
48 | 48 | ||
49 | case 'only-video': | 49 | case 'only-video': |
50 | res.locals.onlyVideo = video as MVideoThumbnail | 50 | res.locals.onlyVideo = video as MVideoThumbnail |
51 | break | 51 | break |
52 | |||
53 | case 'only-video-with-rights': | ||
54 | res.locals.onlyVideoWithRights = video as MVideoWithRights | ||
55 | break | ||
56 | } | 52 | } |
57 | 53 | ||
58 | return true | 54 | 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' | |||
4 | import { isAbleToUploadVideo } from '@server/lib/user' | 4 | import { isAbleToUploadVideo } from '@server/lib/user' |
5 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { ExpressPromiseHandler } from '@server/types/express' | 6 | import { ExpressPromiseHandler } from '@server/types/express' |
7 | import { MUserAccountId, MVideoWithRights } from '@server/types/models' | 7 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' |
8 | import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' | 8 | import { ServerErrorCode, UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' |
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
10 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/change-ownership/video-change-ownership-accept.model' | 10 | 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 | |||
258 | } | 258 | } |
259 | 259 | ||
260 | const videosCustomGetValidator = ( | 260 | const videosCustomGetValidator = ( |
261 | fetchType: 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'only-immutable-attributes', | 261 | fetchType: 'for-api' | 'all' | 'only-video' | 'only-immutable-attributes', |
262 | authenticateInQuery = false | 262 | authenticateInQuery = false |
263 | ) => { | 263 | ) => { |
264 | return [ | 264 | return [ |
@@ -273,7 +273,7 @@ const videosCustomGetValidator = ( | |||
273 | // Controllers does not need to check video rights | 273 | // Controllers does not need to check video rights |
274 | if (fetchType === 'only-immutable-attributes') return next() | 274 | if (fetchType === 'only-immutable-attributes') return next() |
275 | 275 | ||
276 | const video = getVideoWithAttributes(res) as MVideoWithRights | 276 | const video = getVideoWithAttributes(res) as MVideoFullLight |
277 | 277 | ||
278 | // Video private or blacklisted | 278 | // Video private or blacklisted |
279 | if (video.requiresAuth()) { | 279 | if (video.requiresAuth()) { |