From 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 Mon Sep 17 00:00:00 2001 From: Josh Morel Date: Tue, 2 Apr 2019 05:26:47 -0400 Subject: add quarantine videos feature (#1637) * add quarantine videos feature * increase Notification settings test timeout to 20000ms. was completing 7000 locally but timing out after 10000 on travis * fix quarantine video test issues -propagate misspelling -remove skip from server/tests/client.ts * WIP use blacklist for moderator video approval instead of video.quarantine boolean * finish auto-blacklist feature --- server/controllers/api/videos/import.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'server/controllers/api/videos/import.ts') diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index cbd2e8514..c234a1391 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -18,10 +18,12 @@ import { join } from 'path' import { isArray } from '../../../helpers/custom-validators/misc' import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' import { VideoChannelModel } from '../../../models/video/video-channel' +import { UserModel } from '../../../models/account/user' import * as Bluebird from 'bluebird' import * as parseTorrent from 'parse-torrent' import { getSecureTorrentName } from '../../../helpers/utils' import { readFile, move } from 'fs-extra' +import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() @@ -85,7 +87,7 @@ async function addTorrentImport (req: express.Request, res: express.Response, to videoName = isArray(parsed.name) ? parsed.name[ 0 ] : parsed.name as string } - const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }) + const video = buildVideo(res.locals.videoChannel.id, body, { name: videoName }, user) await processThumbnail(req, video) await processPreview(req, video) @@ -128,7 +130,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) }).end() } - const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo) + const video = buildVideo(res.locals.videoChannel.id, body, youtubeDLInfo, user) const downloadThumbnail = !await processThumbnail(req, video) const downloadPreview = !await processPreview(req, video) @@ -156,7 +158,7 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) return res.json(videoImport.toFormattedJSON()).end() } -function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo) { +function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo, user: UserModel) { const videoData = { name: body.name || importData.name || 'Unknown name', remote: false, @@ -218,6 +220,8 @@ function insertIntoDB ( const videoCreated = await video.save(sequelizeOptions) videoCreated.VideoChannel = videoChannel + await autoBlacklistVideoIfNeeded(video, videoChannel.Account.User, t) + // Set tags to the video if (tags) { const tagInstances = await TagModel.findOrCreateTags(tags, t) -- cgit v1.2.3