aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-03 11:03:30 +0100
committerChocobozzz <me@florianbigard.com>2021-03-03 11:03:30 +0100
commit6c9c3b7b14411a854c8dcf8583d56b314e45a4ce (patch)
treeafc86f88b33a4ad79a0d6e61a049e3693a44df23 /server/lib
parent1ef447bd8397792dc7d1db93dfe87749f0532c72 (diff)
downloadPeerTube-6c9c3b7b14411a854c8dcf8583d56b314e45a4ce.tar.gz
PeerTube-6c9c3b7b14411a854c8dcf8583d56b314e45a4ce.tar.zst
PeerTube-6c9c3b7b14411a854c8dcf8583d56b314e45a4ce.zip
Fix emptying video tags
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/videos.ts2
-rw-r--r--server/lib/video.ts18
2 files changed, 8 insertions, 12 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index c29bcc528..c02578aad 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -440,7 +440,7 @@ async function updateVideoFromAP (options: {
440 const tags = videoObject.tag 440 const tags = videoObject.tag
441 .filter(isAPHashTagObject) 441 .filter(isAPHashTagObject)
442 .map(tag => tag.name) 442 .map(tag => tag.name)
443 await setVideoTags({ video: videoUpdated, tags, transaction: t, defaultValue: videoUpdated.Tags }) 443 await setVideoTags({ video: videoUpdated, tags, transaction: t })
444 } 444 }
445 445
446 // Update trackers 446 // Update trackers
diff --git a/server/lib/video.ts b/server/lib/video.ts
index 6b75fadb0..e381e0a69 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -4,7 +4,7 @@ import { sequelizeTypescript } from '@server/initializers/database'
4import { TagModel } from '@server/models/video/tag' 4import { TagModel } from '@server/models/video/tag'
5import { VideoModel } from '@server/models/video/video' 5import { VideoModel } from '@server/models/video/video'
6import { FilteredModelAttributes } from '@server/types' 6import { FilteredModelAttributes } from '@server/types'
7import { MTag, MThumbnail, MUserId, MVideo, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' 7import { MThumbnail, MUserId, MVideo, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models'
8import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } from '@shared/models' 8import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } from '@shared/models'
9import { federateVideoIfNeeded } from './activitypub/videos' 9import { federateVideoIfNeeded } from './activitypub/videos'
10import { JobQueue } from './job-queue/job-queue' 10import { JobQueue } from './job-queue/job-queue'
@@ -69,18 +69,14 @@ async function setVideoTags (options: {
69 video: MVideoTag 69 video: MVideoTag
70 tags: string[] 70 tags: string[]
71 transaction?: Transaction 71 transaction?: Transaction
72 defaultValue?: MTag[]
73}) { 72}) {
74 const { video, tags, transaction, defaultValue } = options 73 const { video, tags, transaction } = options
75 // Set tags to the video
76 if (tags) {
77 const tagInstances = await TagModel.findOrCreateTags(tags, transaction)
78 74
79 await video.$set('Tags', tagInstances, { transaction }) 75 const internalTags = tags || []
80 video.Tags = tagInstances 76 const tagInstances = await TagModel.findOrCreateTags(internalTags, transaction)
81 } else { 77
82 video.Tags = defaultValue || [] 78 await video.$set('Tags', tagInstances, { transaction })
83 } 79 video.Tags = tagInstances
84} 80}
85 81
86async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) { 82async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) {