X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideos%2Fimport.ts;h=dcba0e08f4a2372505de2d71615cd4eb408c2735;hb=b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62;hp=bfb69090652a340261f80824442c34be315d16bd;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;p=github%2FChocobozzz%2FPeerTube.git 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) {