-async function isVideoExist (id: string, res: Response) {
- let video: VideoModel
-
- if (validator.isInt(id)) {
- video = await VideoModel.loadAndPopulateAccountAndServerAndTags(+id)
- } else { // UUID
- video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id)
- }
-
- if (!video) {
- res.status(404)
- .json({ error: 'Video not found' })
- .end()
-
- return false
- }
-
- res.locals.video = video
- return true
-}
-
-async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) {
- if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) {
- const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId)
- if (!videoChannel) {
- res.status(400)
- .json({ error: 'Unknown video video channel on this instance.' })
- .end()
-
- return false
- }
-
- res.locals.videoChannel = videoChannel
- return true
- }
-
- const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id)
- if (!videoChannel) {
- res.status(400)
- .json({ error: 'Unknown video video channel for this account.' })
- .end()
-
- return false
- }