1
0
Fork 0

Fix invalid state change notif of remote live

This commit is contained in:
Chocobozzz 2023-12-15 15:58:07 +01:00
parent 4662badde7
commit 1e121c9898
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 11 additions and 6 deletions

View file

@ -86,9 +86,13 @@ describe('Test live socket messages', function () {
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers) await waitJobs(servers)
// Ensure remote server doesn't send multiple times the state change event to viewers
await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'my new live name' } })
await waitJobs(servers)
for (const stateChanges of [ localStateChanges, remoteStateChanges ]) { for (const stateChanges of [ localStateChanges, remoteStateChanges ]) {
expect(stateChanges).to.have.length.at.least(1) expect(stateChanges).to.have.lengthOf(1)
expect(stateChanges[stateChanges.length - 1]).to.equal(VideoState.PUBLISHED) expect(stateChanges[0]).to.equal(VideoState.PUBLISHED)
} }
await stopFfmpeg(ffmpegCommand) await stopFfmpeg(ffmpegCommand)

View file

@ -53,6 +53,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
this.checkChannelUpdateOrThrow(channelActor) this.checkChannelUpdateOrThrow(channelActor)
const oldState = this.video.state
const videoUpdated = await this.updateVideo(channelActor.VideoChannel, undefined, overrideTo) const videoUpdated = await this.updateVideo(channelActor.VideoChannel, undefined, overrideTo)
if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel) if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel)
@ -95,7 +96,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
Notifier.Instance.notifyOnNewVideoIfNeeded(videoUpdated) Notifier.Instance.notifyOnNewVideoIfNeeded(videoUpdated)
} }
if (videoUpdated.isLive) { if (videoUpdated.isLive && oldState !== videoUpdated.state) {
PeerTubeSocket.Instance.sendVideoLiveNewState(videoUpdated) PeerTubeSocket.Instance.sendVideoLiveNewState(videoUpdated)
} }

View file

@ -48,7 +48,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
private async updateAVideo (schedule: MScheduleVideoUpdate) { private async updateAVideo (schedule: MScheduleVideoUpdate) {
let oldPrivacy: VideoPrivacyType let oldPrivacy: VideoPrivacyType
let isNewVideo: boolean let isNewVideoForFederation: boolean
let published = false let published = false
const video = await sequelizeTypescript.transaction(async t => { const video = await sequelizeTypescript.transaction(async t => {
@ -58,7 +58,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
logger.info('Executing scheduled video update on %s.', video.uuid) logger.info('Executing scheduled video update on %s.', video.uuid)
if (schedule.privacy) { if (schedule.privacy) {
isNewVideo = video.isNewVideoForFederation(schedule.privacy) isNewVideoForFederation = video.isNewVideoForFederation(schedule.privacy)
oldPrivacy = video.privacy oldPrivacy = video.privacy
setVideoPrivacy(video, schedule.privacy) setVideoPrivacy(video, schedule.privacy)
@ -78,7 +78,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
return { video, published: false } return { video, published: false }
} }
await addVideoJobsAfterUpdate({ video, oldPrivacy, isNewVideo, nameChanged: false }) await addVideoJobsAfterUpdate({ video, oldPrivacy, isNewVideoForFederation, nameChanged: false })
return { video, published } return { video, published }
} }