diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-07 15:04:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-07 15:04:41 +0200 |
commit | b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62 (patch) | |
tree | 754bb49026d4df8086030e28a8a7c16e3f0338b6 /server/controllers/api | |
parent | 851f5daa1eec66e1faa3c45238ec9ab91be05b00 (diff) | |
parent | 03371ad9d049bab79445a1b35da44cb1272f6c28 (diff) | |
download | PeerTube-b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62.tar.gz PeerTube-b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62.tar.zst PeerTube-b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62.zip |
Merge branch 'release/v1.3.0' into develop
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/videos/import.ts | 16 |
1 files changed, 10 insertions, 6 deletions
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' | |||
26 | import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail' | 26 | import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail' |
27 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 27 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
28 | import { ThumbnailModel } from '../../../models/video/thumbnail' | 28 | import { ThumbnailModel } from '../../../models/video/thumbnail' |
29 | import { UserModel } from '../../../models/account/user' | ||
29 | 30 | ||
30 | const auditLogger = auditLoggerFactory('video-imports') | 31 | const auditLogger = auditLoggerFactory('video-imports') |
31 | const videoImportsRouter = express.Router() | 32 | const videoImportsRouter = express.Router() |
@@ -107,7 +108,8 @@ async function addTorrentImport (req: express.Request, res: express.Response, to | |||
107 | previewModel, | 108 | previewModel, |
108 | videoChannel: res.locals.videoChannel, | 109 | videoChannel: res.locals.videoChannel, |
109 | tags, | 110 | tags, |
110 | videoImportAttributes | 111 | videoImportAttributes, |
112 | user | ||
111 | }) | 113 | }) |
112 | 114 | ||
113 | // Create job to import the video | 115 | // Create job to import the video |
@@ -151,12 +153,13 @@ async function addYoutubeDLImport (req: express.Request, res: express.Response) | |||
151 | userId: user.id | 153 | userId: user.id |
152 | } | 154 | } |
153 | const videoImport = await insertIntoDB({ | 155 | const videoImport = await insertIntoDB({ |
154 | video: video, | 156 | video, |
155 | thumbnailModel, | 157 | thumbnailModel, |
156 | previewModel, | 158 | previewModel, |
157 | videoChannel: res.locals.videoChannel, | 159 | videoChannel: res.locals.videoChannel, |
158 | tags, | 160 | tags, |
159 | videoImportAttributes | 161 | videoImportAttributes, |
162 | user | ||
160 | }) | 163 | }) |
161 | 164 | ||
162 | // Create job to import the video | 165 | // Create job to import the video |
@@ -227,9 +230,10 @@ function insertIntoDB (parameters: { | |||
227 | previewModel: ThumbnailModel, | 230 | previewModel: ThumbnailModel, |
228 | videoChannel: VideoChannelModel, | 231 | videoChannel: VideoChannelModel, |
229 | tags: string[], | 232 | tags: string[], |
230 | videoImportAttributes: Partial<VideoImportModel> | 233 | videoImportAttributes: Partial<VideoImportModel>, |
234 | user: UserModel | ||
231 | }): Bluebird<VideoImportModel> { | 235 | }): Bluebird<VideoImportModel> { |
232 | let { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes } = parameters | 236 | const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters |
233 | 237 | ||
234 | return sequelizeTypescript.transaction(async t => { | 238 | return sequelizeTypescript.transaction(async t => { |
235 | const sequelizeOptions = { transaction: t } | 239 | const sequelizeOptions = { transaction: t } |
@@ -241,7 +245,7 @@ function insertIntoDB (parameters: { | |||
241 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) | 245 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) |
242 | if (previewModel) await videoCreated.addAndSaveThumbnail(previewModel, t) | 246 | if (previewModel) await videoCreated.addAndSaveThumbnail(previewModel, t) |
243 | 247 | ||
244 | await autoBlacklistVideoIfNeeded(video, videoChannel.Account.User, t) | 248 | await autoBlacklistVideoIfNeeded(video, user, t) |
245 | 249 | ||
246 | // Set tags to the video | 250 | // Set tags to the video |
247 | if (tags) { | 251 | if (tags) { |