diff options
Diffstat (limited to 'server/lib/video.ts')
-rw-r--r-- | server/lib/video.ts | 18 |
1 files changed, 7 insertions, 11 deletions
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' | |||
4 | import { TagModel } from '@server/models/video/tag' | 4 | import { TagModel } from '@server/models/video/tag' |
5 | import { VideoModel } from '@server/models/video/video' | 5 | import { VideoModel } from '@server/models/video/video' |
6 | import { FilteredModelAttributes } from '@server/types' | 6 | import { FilteredModelAttributes } from '@server/types' |
7 | import { MTag, MThumbnail, MUserId, MVideo, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' | 7 | import { MThumbnail, MUserId, MVideo, MVideoFile, MVideoTag, MVideoThumbnail, MVideoUUID } from '@server/types/models' |
8 | import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } from '@shared/models' | 8 | import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } from '@shared/models' |
9 | import { federateVideoIfNeeded } from './activitypub/videos' | 9 | import { federateVideoIfNeeded } from './activitypub/videos' |
10 | import { JobQueue } from './job-queue/job-queue' | 10 | import { 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 | ||
86 | async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) { | 82 | async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) { |