diff options
Diffstat (limited to 'server/lib/model-loaders')
-rw-r--r-- | server/lib/model-loaders/video.ts | 14 |
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 @@ | |||
1 | import { VideoModel } from '@server/models/video/video' | 1 | import { VideoModel } from '@server/models/video/video' |
2 | import { | 2 | import { |
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' |
11 | import { Hooks } from '../plugins/hooks' | ||
10 | 12 | ||
11 | type VideoLoadType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 13 | type VideoLoadType = 'for-api' | 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
12 | 14 | ||
15 | function loadVideo (id: number | string, fetchType: 'for-api', userId?: number): Promise<MVideoFormattableDetails> | ||
13 | function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> | 16 | function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> |
14 | function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> | 17 | function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
15 | function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> | 18 | function 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) |