aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-09-17 10:00:46 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commit1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb (patch)
tree8bb02f8dc2590e5071306fb311bdc53289e20336 /server/lib/activitypub/videos.ts
parentc6c0fa6cd8fe8f752463d8982c3dbcd448739c4e (diff)
downloadPeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.tar.gz
PeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.tar.zst
PeerTube-1ef65f4c034cc53ab5d55417e52d60e1f7fc1ddb.zip
Refactor video creation
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index cbbf23be1..096884776 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -68,6 +68,7 @@ import { ActorFollowScoreCache } from '../files-cache'
68import { JobQueue } from '../job-queue' 68import { JobQueue } from '../job-queue'
69import { Notifier } from '../notifier' 69import { Notifier } from '../notifier'
70import { createPlaceholderThumbnail, createVideoMiniatureFromUrl } from '../thumbnail' 70import { createPlaceholderThumbnail, createVideoMiniatureFromUrl } from '../thumbnail'
71import { setVideoTags } from '../video'
71import { autoBlacklistVideoIfNeeded } from '../video-blacklist' 72import { autoBlacklistVideoIfNeeded } from '../video-blacklist'
72import { getOrCreateActorAndServerAndModel } from './actor' 73import { getOrCreateActorAndServerAndModel } from './actor'
73import { crawlCollectionPage } from './crawl' 74import { crawlCollectionPage } from './crawl'
@@ -409,8 +410,7 @@ async function updateVideoFromAP (options: {
409 const tags = videoObject.tag 410 const tags = videoObject.tag
410 .filter(isAPHashTagObject) 411 .filter(isAPHashTagObject)
411 .map(tag => tag.name) 412 .map(tag => tag.name)
412 const tagInstances = await TagModel.findOrCreateTags(tags, t) 413 await setVideoTags({ video: videoUpdated, tags, transaction: t, defaultValue: videoUpdated.Tags })
413 await videoUpdated.$set('Tags', tagInstances, sequelizeOptions)
414 } 414 }
415 415
416 { 416 {
@@ -594,8 +594,7 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
594 const tags = videoObject.tag 594 const tags = videoObject.tag
595 .filter(isAPHashTagObject) 595 .filter(isAPHashTagObject)
596 .map(t => t.name) 596 .map(t => t.name)
597 const tagInstances = await TagModel.findOrCreateTags(tags, t) 597 await setVideoTags({ video: videoCreated, tags, transaction: t })
598 await videoCreated.$set('Tags', tagInstances, sequelizeOptions)
599 598
600 // Process captions 599 // Process captions
601 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => { 600 const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
@@ -604,7 +603,6 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
604 await Promise.all(videoCaptionsPromises) 603 await Promise.all(videoCaptionsPromises)
605 604
606 videoCreated.VideoFiles = videoFiles 605 videoCreated.VideoFiles = videoFiles
607 videoCreated.Tags = tagInstances
608 606
609 const autoBlacklisted = await autoBlacklistVideoIfNeeded({ 607 const autoBlacklisted = await autoBlacklistVideoIfNeeded({
610 video: videoCreated, 608 video: videoCreated,