From 03371ad9d049bab79445a1b35da44cb1272f6c28 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 Jun 2019 14:34:11 +0200 Subject: Fix video import if autoblacklist is enabled --- server/controllers/api/videos/import.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index bfb690906..dcba0e08f 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -26,6 +26,7 @@ import { sequelizeTypescript } from '../../../initializers/database' import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail' import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' import { ThumbnailModel } from '../../../models/video/thumbnail' +import { UserModel } from '../../../models/account/user' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() @@ -107,7 +108,8 @@ async function addTorrentImport (req: express.Request, res: express.Response, to previewModel, videoChannel: res.locals.videoChannel, tags, - videoImportAttributes + videoImportAttributes, + user }) // Create job to import the video @@ -151,12 +153,13 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) userId: user.id } const videoImport = await insertIntoDB({ - video: video, + video, thumbnailModel, previewModel, videoChannel: res.locals.videoChannel, tags, - videoImportAttributes + videoImportAttributes, + user }) // Create job to import the video @@ -227,9 +230,10 @@ function insertIntoDB (parameters: { previewModel: ThumbnailModel, videoChannel: VideoChannelModel, tags: string[], - videoImportAttributes: Partial + videoImportAttributes: Partial, + user: UserModel }): Bluebird { - let { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes } = parameters + const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters return sequelizeTypescript.transaction(async t => { const sequelizeOptions = { transaction: t } @@ -241,7 +245,7 @@ function insertIntoDB (parameters: { if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) if (previewModel) await videoCreated.addAndSaveThumbnail(previewModel, t) - await autoBlacklistVideoIfNeeded(video, videoChannel.Account.User, t) + await autoBlacklistVideoIfNeeded(video, user, t) // Set tags to the video if (tags) { -- cgit v1.2.3