aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-12 14:09:04 +0200
committerChocobozzz <me@florianbigard.com>2021-05-12 14:12:14 +0200
commit16c016e8b1d5ca46343d3363f9a49e24c5d7c944 (patch)
tree157dfa22ac95bd76a411aaf78e4df17152530e1c /server/controllers/api/videos
parent9a320a06b663a2e02c3156a07135f75f9e987b11 (diff)
downloadPeerTube-16c016e8b1d5ca46343d3363f9a49e24c5d7c944.tar.gz
PeerTube-16c016e8b1d5ca46343d3363f9a49e24c5d7c944.tar.zst
PeerTube-16c016e8b1d5ca46343d3363f9a49e24c5d7c944.zip
Stricter models typing
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/import.ts9
-rw-r--r--server/controllers/api/videos/index.ts4
2 files changed, 8 insertions, 5 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 4ed58f978..2c225315c 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -5,6 +5,7 @@ import * as parseTorrent from 'parse-torrent'
5import { join } from 'path' 5import { join } from 'path'
6import { getEnabledResolutions } from '@server/lib/config' 6import { getEnabledResolutions } from '@server/lib/config'
7import { setVideoTags } from '@server/lib/video' 7import { setVideoTags } from '@server/lib/video'
8import { FilteredModelAttributes } from '@server/types'
8import { 9import {
9 MChannelAccountDefault, 10 MChannelAccountDefault,
10 MThumbnail, 11 MThumbnail,
@@ -15,7 +16,7 @@ import {
15 MVideoThumbnail, 16 MVideoThumbnail,
16 MVideoWithBlacklistLight 17 MVideoWithBlacklistLight
17} from '@server/types/models' 18} from '@server/types/models'
18import { MVideoImport, MVideoImportFormattable } from '@server/types/models/video/video-import' 19import { MVideoImportFormattable } from '@server/types/models/video/video-import'
19import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared' 20import { ServerErrorCode, VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '../../../../shared'
20import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' 22import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
@@ -253,7 +254,9 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
253 privacy: body.privacy || VideoPrivacy.PRIVATE, 254 privacy: body.privacy || VideoPrivacy.PRIVATE,
254 duration: 0, // duration will be set by the import job 255 duration: 0, // duration will be set by the import job
255 channelId: channelId, 256 channelId: channelId,
256 originallyPublishedAt: body.originallyPublishedAt || importData.originallyPublishedAt 257 originallyPublishedAt: body.originallyPublishedAt
258 ? new Date(body.originallyPublishedAt)
259 : importData.originallyPublishedAt
257 } 260 }
258 const video = new VideoModel(videoData) 261 const video = new VideoModel(videoData)
259 video.url = getLocalVideoActivityPubUrl(video) 262 video.url = getLocalVideoActivityPubUrl(video)
@@ -317,7 +320,7 @@ async function insertIntoDB (parameters: {
317 previewModel: MThumbnail 320 previewModel: MThumbnail
318 videoChannel: MChannelAccountDefault 321 videoChannel: MChannelAccountDefault
319 tags: string[] 322 tags: string[]
320 videoImportAttributes: Partial<MVideoImport> 323 videoImportAttributes: FilteredModelAttributes<VideoImportModel>
321 user: MUser 324 user: MUser
322}): Promise<MVideoImportFormattable> { 325}): Promise<MVideoImportFormattable> {
323 const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters 326 const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parameters
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index c32626d30..f5ce15074 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -308,7 +308,7 @@ async function addVideo (options: {
308 if (videoInfo.scheduleUpdate) { 308 if (videoInfo.scheduleUpdate) {
309 await ScheduleVideoUpdateModel.create({ 309 await ScheduleVideoUpdateModel.create({
310 videoId: video.id, 310 videoId: video.id,
311 updateAt: videoInfo.scheduleUpdate.updateAt, 311 updateAt: new Date(videoInfo.scheduleUpdate.updateAt),
312 privacy: videoInfo.scheduleUpdate.privacy || null 312 privacy: videoInfo.scheduleUpdate.privacy || null
313 }, { transaction: t }) 313 }, { transaction: t })
314 } 314 }
@@ -435,7 +435,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
435 if (videoInfoToUpdate.scheduleUpdate) { 435 if (videoInfoToUpdate.scheduleUpdate) {
436 await ScheduleVideoUpdateModel.upsert({ 436 await ScheduleVideoUpdateModel.upsert({
437 videoId: videoInstanceUpdated.id, 437 videoId: videoInstanceUpdated.id,
438 updateAt: videoInfoToUpdate.scheduleUpdate.updateAt, 438 updateAt: new Date(videoInfoToUpdate.scheduleUpdate.updateAt),
439 privacy: videoInfoToUpdate.scheduleUpdate.privacy || null 439 privacy: videoInfoToUpdate.scheduleUpdate.privacy || null
440 }, { transaction: t }) 440 }, { transaction: t })
441 } else if (videoInfoToUpdate.scheduleUpdate === null) { 441 } else if (videoInfoToUpdate.scheduleUpdate === null) {