import { UserRight, VideoPrivacy, VideoRateType } from '../../../shared'
import {
CONSTRAINTS_FIELDS,
- VIDEO_ABUSE_STATES,
VIDEO_CATEGORIES,
VIDEO_LICENCES,
VIDEO_MIMETYPE_EXT,
import { VideoChannelModel } from '../../models/video/video-channel'
import { UserModel } from '../../models/account/user'
import * as magnetUtil from 'magnet-uri'
-import { VideoAbuseModel } from '../../models/video/video-abuse'
+import { fetchVideo, VideoFetchType } from '../video'
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
-const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
function isVideoCategoryValid (value: any) {
return value === null || VIDEO_CATEGORIES[ value ] !== undefined
return true
}
-async function isVideoExist (id: string, res: Response) {
- let video: VideoModel | null
-
- if (validator.isInt(id)) {
- video = await VideoModel.loadAndPopulateAccountAndServerAndTags(+id)
- } else { // UUID
- video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id)
- }
+async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') {
+ const video = await fetchVideo(id, fetchType)
if (video === null) {
res.status(404)
return false
}
- res.locals.video = video
+ if (fetchType !== 'none') res.locals.video = video
return true
}
const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId)
if (videoChannel === null) {
res.status(400)
- .json({ error: 'Unknown video video channel on this instance.' })
+ .json({ error: 'Unknown video `video channel` on this instance.' })
.end()
return false
const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id)
if (videoChannel === null) {
res.status(400)
- .json({ error: 'Unknown video video channel for this account.' })
+ .json({ error: 'Unknown video `video channel` for this account.' })
.end()
return false