aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/model-loaders/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/model-loaders/video.ts')
-rw-r--r--server/lib/model-loaders/video.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/lib/model-loaders/video.ts b/server/lib/model-loaders/video.ts
index 597c94395..07b373ed3 100644
--- a/server/lib/model-loaders/video.ts
+++ b/server/lib/model-loaders/video.ts
@@ -1,15 +1,18 @@
1import { VideoModel } from '@server/models/video/video' 1import { VideoModel } from '@server/models/video/video'
2import { 2import {
3 MVideoAccountLightBlacklistAllFiles, 3 MVideoAccountLightBlacklistAllFiles,
4 MVideoFormattableDetails,
4 MVideoFullLight, 5 MVideoFullLight,
5 MVideoIdThumbnail, 6 MVideoIdThumbnail,
6 MVideoImmutable, 7 MVideoImmutable,
7 MVideoThumbnail, 8 MVideoThumbnail,
8 MVideoWithRights 9 MVideoWithRights
9} from '@server/types/models' 10} from '@server/types/models'
11import { Hooks } from '../plugins/hooks'
10 12
11type VideoLoadType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' 13type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
12 14
15function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails>
13function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> 16function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>
14function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> 17function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
15function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> 18function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
@@ -25,6 +28,15 @@ function loadVideo (
25 fetchType: VideoLoadType, 28 fetchType: VideoLoadType,
26 userId?: number 29 userId?: number
27): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { 30): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> {
31
32 if (fetchType === 'for-api') {
33 return Hooks.wrapPromiseFun(
34 VideoModel.loadForGetAPI,
35 { id, userId },
36 'filter:api.video.get.result'
37 )
38 }
39
28 if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) 40 if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
29 41
30 if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) 42 if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)