From 5e82c1932eb0487e55ae75417f9dc11fc585cfde Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 5 Aug 2024 15:02:30 +0200 Subject: [PATCH] Correctly set tags to replays of permanent lives --- packages/tests/src/api/live/live-save-replay.ts | 11 +++++++++++ .../core/lib/job-queue/handlers/video-live-ending.ts | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/tests/src/api/live/live-save-replay.ts b/packages/tests/src/api/live/live-save-replay.ts index cc8cbe410..b91a050bf 100644 --- a/packages/tests/src/api/live/live-save-replay.ts +++ b/packages/tests/src/api/live/live-save-replay.ts @@ -48,6 +48,7 @@ describe('Save replay setting', function () { channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, name: 'live'.repeat(30), + tags: [ 'tag1', 'tag2' ], saveReplay: options.replay, replaySettings: options.replaySettings, permanentLive: options.permanent @@ -134,6 +135,13 @@ describe('Save replay setting', function () { } } + async function checkVideoTags (videoId: string, tags: string[]) { + for (const server of servers) { + const video = await server.videos.get({ id: videoId }) + expect(video.tags).to.have.members(tags) + } + } + before(async function () { this.timeout(120000) @@ -311,6 +319,7 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, 0, HttpStatusCode.OK_200) await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) await checkVideoPrivacy(liveVideoUUID, VideoPrivacy.UNLISTED) + await checkVideoTags(liveVideoUUID, [ 'tag1', 'tag2' ]) }) it('Should find the replay live session', async function () { @@ -443,6 +452,8 @@ describe('Save replay setting', function () { await waitJobs(servers) await servers[1].videos.get({ id: lastReplayUUID, expectedStatus: HttpStatusCode.OK_200 }) + + await checkVideoTags(lastReplayUUID, [ 'tag1', 'tag2' ]) }) it('Should have appropriate ended session and replay live session', async function () { diff --git a/server/core/lib/job-queue/handlers/video-live-ending.ts b/server/core/lib/job-queue/handlers/video-live-ending.ts index b8c9020f7..dba971649 100644 --- a/server/core/lib/job-queue/handlers/video-live-ending.ts +++ b/server/core/lib/job-queue/handlers/video-live-ending.ts @@ -18,6 +18,7 @@ import { buildStoryboardJobIfNeeded } from '@server/lib/video-jobs.js' import { VideoPathManager } from '@server/lib/video-path-manager.js' import { isVideoInPublicDirectory } from '@server/lib/video-privacy.js' import { moveToNextState } from '@server/lib/video-state.js' +import { setVideoTags } from '@server/lib/video.js' import { VideoBlacklistModel } from '@server/models/video/video-blacklist.js' import { VideoFileModel } from '@server/models/video/video-file.js' import { VideoLiveReplaySettingModel } from '@server/models/video/video-live-replay-setting.js' @@ -30,6 +31,7 @@ import { MVideo, MVideoLive, MVideoLiveSession, + MVideoTag, MVideoThumbnail, MVideoWithAllFiles, MVideoWithFileThumbnail @@ -110,8 +112,9 @@ async function saveReplayToExternalVideo (options: { publishedAt: string replayDirectory: string }) { - const { liveVideo, liveSession, publishedAt, replayDirectory } = options + const { liveSession, publishedAt, replayDirectory } = options + const liveVideo = await VideoModel.loadFull(options.liveVideo.id) const replaySettings = await VideoLiveReplaySettingModel.load(liveSession.replaySettingId) const videoNameSuffix = ` - ${new Date(publishedAt).toLocaleString()}` @@ -138,7 +141,7 @@ async function saveReplayToExternalVideo (options: { support: liveVideo.support, privacy: replaySettings.privacy, channelId: liveVideo.channelId - }) as MVideoWithAllFiles + }) as MVideoWithAllFiles & MVideoTag replayVideo.Thumbnails = [] replayVideo.VideoFiles = [] @@ -148,6 +151,8 @@ async function saveReplayToExternalVideo (options: { await replayVideo.save() + await setVideoTags({ video: replayVideo, tags: liveVideo.Tags.map(t => t.name) }) + liveSession.replayVideoId = replayVideo.id await liveSession.save()