aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/video.ts')
-rw-r--r--server/helpers/video.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/server/helpers/video.ts b/server/helpers/video.ts
index 26a72ac5c..d066e2b1f 100644
--- a/server/helpers/video.ts
+++ b/server/helpers/video.ts
@@ -1,6 +1,12 @@
1import { VideoModel } from '../models/video/video' 1import { VideoModel } from '../models/video/video'
2import * as Bluebird from 'bluebird' 2import * as Bluebird from 'bluebird'
3import { MVideoAccountAllFiles, MVideoFullLight, MVideoThumbnail, MVideoWithRights, MVideoIdThumbnail } from '@server/typings/models' 3import {
4 MVideoAccountLightBlacklistAllFiles,
5 MVideoFullLight,
6 MVideoIdThumbnail,
7 MVideoThumbnail,
8 MVideoWithRights
9} from '@server/typings/models'
4import { Response } from 'express' 10import { Response } from 'express'
5 11
6type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' 12type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
@@ -30,10 +36,10 @@ function fetchVideo (
30 36
31type VideoFetchByUrlType = 'all' | 'only-video' 37type VideoFetchByUrlType = 'all' | 'only-video'
32 38
33function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird<MVideoAccountAllFiles> 39function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird<MVideoAccountLightBlacklistAllFiles>
34function fetchVideoByUrl (url: string, fetchType: 'only-video'): Bluebird<MVideoThumbnail> 40function fetchVideoByUrl (url: string, fetchType: 'only-video'): Bluebird<MVideoThumbnail>
35function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountAllFiles> | Bluebird<MVideoThumbnail> 41function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail>
36function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountAllFiles> | Bluebird<MVideoThumbnail> { 42function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail> {
37 if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) 43 if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
38 44
39 if (fetchType === 'only-video') return VideoModel.loadByUrl(url) 45 if (fetchType === 'only-video') return VideoModel.loadByUrl(url)
@@ -43,10 +49,15 @@ function getVideo (res: Response) {
43 return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights || res.locals.videoId 49 return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights || res.locals.videoId
44} 50}
45 51
52function getVideoWithAttributes (res: Response) {
53 return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights
54}
55
46export { 56export {
47 VideoFetchType, 57 VideoFetchType,
48 VideoFetchByUrlType, 58 VideoFetchByUrlType,
49 fetchVideo, 59 fetchVideo,
50 getVideo, 60 getVideo,
61 getVideoWithAttributes,
51 fetchVideoByUrl 62 fetchVideoByUrl
52} 63}