diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-20 19:05:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-20 19:23:10 +0200 |
commit | 1ca9f7c3f7afac2af4c4c25b98426731f7e789c6 (patch) | |
tree | 27fe65c4ea5e9250d2523033d5c65b315bfca23d /server/controllers/api/videos | |
parent | 0283eaac2a8e73006c66df3cf5bb9012e37450e5 (diff) | |
download | PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.gz PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.zst PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.zip |
Type toFormattedJSON
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/import.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index e7adcc35a..8879f3442 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as magnetUtil from 'magnet-uri' | 2 | import * as magnetUtil from 'magnet-uri' |
3 | import 'multer' | ||
4 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' | 3 | import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger' |
5 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' | 4 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' |
6 | import { MIMETYPES } from '../../../initializers/constants' | 5 | import { MIMETYPES } from '../../../initializers/constants' |
@@ -28,11 +27,12 @@ import { | |||
28 | MChannelAccountDefault, | 27 | MChannelAccountDefault, |
29 | MThumbnail, | 28 | MThumbnail, |
30 | MUser, | 29 | MUser, |
30 | MVideoAccountDefault, | ||
31 | MVideoTag, | 31 | MVideoTag, |
32 | MVideoThumbnailAccountDefault, | 32 | MVideoThumbnailAccountDefault, |
33 | MVideoWithBlacklistLight | 33 | MVideoWithBlacklistLight |
34 | } from '@server/typings/models' | 34 | } from '@server/typings/models' |
35 | import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import' | 35 | import { MVideoImport, MVideoImportFormattable } from '@server/typings/models/video/video-import' |
36 | 36 | ||
37 | const auditLogger = auditLoggerFactory('video-imports') | 37 | const auditLogger = auditLoggerFactory('video-imports') |
38 | const videoImportsRouter = express.Router() | 38 | const videoImportsRouter = express.Router() |
@@ -238,14 +238,14 @@ function insertIntoDB (parameters: { | |||
238 | tags: string[], | 238 | tags: string[], |
239 | videoImportAttributes: Partial<MVideoImport>, | 239 | videoImportAttributes: Partial<MVideoImport>, |
240 | user: MUser | 240 | user: MUser |
241 | }): Bluebird<MVideoImportVideo> { | 241 | }): Bluebird<MVideoImportFormattable> { |
242 | const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters | 242 | const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters |
243 | 243 | ||
244 | return sequelizeTypescript.transaction(async t => { | 244 | return sequelizeTypescript.transaction(async t => { |
245 | const sequelizeOptions = { transaction: t } | 245 | const sequelizeOptions = { transaction: t } |
246 | 246 | ||
247 | // Save video object in database | 247 | // Save video object in database |
248 | const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight & MVideoTag) | 248 | const videoCreated = await video.save(sequelizeOptions) as (MVideoAccountDefault & MVideoWithBlacklistLight & MVideoTag) |
249 | videoCreated.VideoChannel = videoChannel | 249 | videoCreated.VideoChannel = videoChannel |
250 | 250 | ||
251 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) | 251 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) |
@@ -274,7 +274,7 @@ function insertIntoDB (parameters: { | |||
274 | const videoImport = await VideoImportModel.create( | 274 | const videoImport = await VideoImportModel.create( |
275 | Object.assign({ videoId: videoCreated.id }, videoImportAttributes), | 275 | Object.assign({ videoId: videoCreated.id }, videoImportAttributes), |
276 | sequelizeOptions | 276 | sequelizeOptions |
277 | ) as MVideoImportVideo | 277 | ) as MVideoImportFormattable |
278 | videoImport.Video = videoCreated | 278 | videoImport.Video = videoCreated |
279 | 279 | ||
280 | return videoImport | 280 | return videoImport |