1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add ability to remove a video import

This commit is contained in:
Chocobozzz 2018-08-02 16:33:29 +02:00
parent ce32426be9
commit 299474e827
5 changed files with 47 additions and 7 deletions

View file

@ -3,6 +3,9 @@ import 'multer'
import * as validator from 'validator'
import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers'
import { exists } from './misc'
import * as express from 'express'
import { VideoChannelModel } from '../../models/video/video-channel'
import { VideoImportModel } from '../../models/video/video-import'
function isVideoImportTargetUrlValid (url: string) {
const isURLOptions = {
@ -22,9 +25,25 @@ function isVideoImportStateValid (value: any) {
return exists(value) && VIDEO_IMPORT_STATES[ value ] !== undefined
}
async function isVideoImportExist (id: number, res: express.Response) {
const videoImport = await VideoImportModel.loadAndPopulateVideo(id)
if (!videoImport) {
res.status(404)
.json({ error: 'Video import not found' })
.end()
return false
}
res.locals.videoImport = videoImport
return true
}
// ---------------------------------------------------------------------------
export {
isVideoImportStateValid,
isVideoImportTargetUrlValid
isVideoImportTargetUrlValid,
isVideoImportExist
}