aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/index.ts13
-rw-r--r--server/lib/activitypub/videos.ts2
-rw-r--r--server/lib/video.ts18
3 files changed, 15 insertions, 18 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 58ab72370..2447c1288 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -347,12 +347,13 @@ async function updateVideo (req: express.Request, res: express.Response) {
347 if (previewModel) await videoInstanceUpdated.addAndSaveThumbnail(previewModel, t) 347 if (previewModel) await videoInstanceUpdated.addAndSaveThumbnail(previewModel, t)
348 348
349 // Video tags update? 349 // Video tags update?
350 await setVideoTags({ 350 if (videoInfoToUpdate.tags !== undefined) {
351 video: videoInstanceUpdated, 351 await setVideoTags({
352 tags: videoInfoToUpdate.tags, 352 video: videoInstanceUpdated,
353 transaction: t, 353 tags: videoInfoToUpdate.tags,
354 defaultValue: videoInstanceUpdated.Tags 354 transaction: t
355 }) 355 })
356 }
356 357
357 // Video channel update? 358 // Video channel update?
358 if (res.locals.videoChannel && videoInstanceUpdated.channelId !== res.locals.videoChannel.id) { 359 if (res.locals.videoChannel && videoInstanceUpdated.channelId !== res.locals.videoChannel.id) {
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) {