]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/video.ts
Fix jsonld context
[github/Chocobozzz/PeerTube.git] / server / helpers / video.ts
... / ...
CommitLineData
1import { CONFIG } from '../initializers'
2import { VideoModel } from '../models/video/video'
3import { UserRight } from '../../shared'
4import { UserModel } from '../models/account/user'
5
6type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
7
8function fetchVideo (id: number | string, fetchType: VideoFetchType, userId?: number) {
9 if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
10
11 if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
12
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}