]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/video.ts
Fix jsonld context
[github/Chocobozzz/PeerTube.git] / server / helpers / video.ts
CommitLineData
7ccddd7b 1import { CONFIG } from '../initializers'
4157cdb1 2import { VideoModel } from '../models/video/video'
7ccddd7b
JM
3import { UserRight } from '../../shared'
4import { UserModel } from '../models/account/user'
4157cdb1 5
09209296 6type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
4157cdb1 7
6e46de09
C
8function 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
18type VideoFetchByUrlType = 'all' | 'only-video'
19function 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
25export {
26 VideoFetchType,
27 VideoFetchByUrlType,
28 fetchVideo,
29 fetchVideoByUrl
30}