aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/model-loaders
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/model-loaders')
-rw-r--r--server/lib/model-loaders/video.ts13
1 files changed, 5 insertions, 8 deletions
diff --git a/server/lib/model-loaders/video.ts b/server/lib/model-loaders/video.ts
index 07b373ed3..e2bf96f62 100644
--- a/server/lib/model-loaders/video.ts
+++ b/server/lib/model-loaders/video.ts
@@ -3,31 +3,30 @@ import {
3 MVideoAccountLightBlacklistAllFiles, 3 MVideoAccountLightBlacklistAllFiles,
4 MVideoFormattableDetails, 4 MVideoFormattableDetails,
5 MVideoFullLight, 5 MVideoFullLight,
6 MVideoIdThumbnail, 6 MVideoId,
7 MVideoImmutable, 7 MVideoImmutable,
8 MVideoThumbnail, 8 MVideoThumbnail,
9 MVideoWithRights 9 MVideoWithRights
10} from '@server/types/models' 10} from '@server/types/models'
11import { Hooks } from '../plugins/hooks' 11import { Hooks } from '../plugins/hooks'
12 12
13type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' 13type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'id' | 'none' | 'only-immutable-attributes'
14 14
15function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails> 15function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails>
16function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> 16function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>
17function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> 17function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
18function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> 18function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
19function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights> 19function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoId>
20function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail>
21function loadVideo ( 20function loadVideo (
22 id: number | string, 21 id: number | string,
23 fetchType: VideoLoadType, 22 fetchType: VideoLoadType,
24 userId?: number 23 userId?: number
25): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> 24): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable>
26function loadVideo ( 25function loadVideo (
27 id: number | string, 26 id: number | string,
28 fetchType: VideoLoadType, 27 fetchType: VideoLoadType,
29 userId?: number 28 userId?: number
30): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { 29): Promise<MVideoFullLight | MVideoThumbnail | MVideoId | MVideoImmutable> {
31 30
32 if (fetchType === 'for-api') { 31 if (fetchType === 'for-api') {
33 return Hooks.wrapPromiseFun( 32 return Hooks.wrapPromiseFun(
@@ -41,8 +40,6 @@ function loadVideo (
41 40
42 if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) 41 if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
43 42
44 if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
45
46 if (fetchType === 'only-video') return VideoModel.load(id) 43 if (fetchType === 'only-video') return VideoModel.load(id)
47 44
48 if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) 45 if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)