]>
Commit | Line | Data |
---|---|---|
7ccddd7b | 1 | import { CONFIG } from '../initializers' |
4157cdb1 | 2 | import { VideoModel } from '../models/video/video' |
7ccddd7b JM |
3 | import { UserRight } from '../../shared' |
4 | import { UserModel } from '../models/account/user' | |
4157cdb1 | 5 | |
09209296 | 6 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' |
4157cdb1 | 7 | |
6e46de09 C |
8 | function fetchVideo (id: number | string, fetchType: VideoFetchType, userId?: number) { |
9 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) | |
4157cdb1 | 10 | |
09209296 C |
11 | if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id) |
12 | ||
4157cdb1 C |
13 | if (fetchType === 'only-video') return VideoModel.load(id) |
14 | ||
15 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) | |
16 | } | |
17 | ||
18 | type VideoFetchByUrlType = 'all' | 'only-video' | |
19 | function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType) { | |
20 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) | |
21 | ||
22 | if (fetchType === 'only-video') return VideoModel.loadByUrl(url) | |
23 | } | |
24 | ||
25 | export { | |
26 | VideoFetchType, | |
27 | VideoFetchByUrlType, | |
28 | fetchVideo, | |
29 | fetchVideoByUrl | |
30 | } |