diff --git a/pkg/spxrpc/place_stream_media_finalizelivestream.go b/pkg/spxrpc/place_stream_media_finalizelivestream.go index 0ac1d9a2c..cf9680046 100644 --- a/pkg/spxrpc/place_stream_media_finalizelivestream.go +++ b/pkg/spxrpc/place_stream_media_finalizelivestream.go @@ -61,19 +61,23 @@ func (s *Server) handlePlaceStreamMediaFinalizeLivestream(ctx context.Context, b return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } + // Create a draft VOD in the 'processing' state, inheriting the livestream's + // metadata and linking back to it via connections. The client no longer polls + // or publishes — the draft reaches 'ready' server-side and the user + // publishes it later from the Drafts tab. + draft, err := s.createLivestreamDraft(ctx, session.DID, uploadID, ls) + if err != nil { + return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + if _, err := s.statefulDB.EnqueueTask(ctx, statedb.TaskFinalizeLivestreamVOD, statedb.FinalizeLivestreamVODTask{ UploadID: uploadID, RepoDID: session.DID, LivestreamURI: body.Livestream, }, statedb.WithTaskKey("finalize-vod:"+uploadID)); err != nil { + _, _ = s.statefulDB.DeleteDraft(ctx, draft.URI) return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - - // Create a draft VOD in the 'processing' state, inheriting the livestream's - // metadata and linking back to it via connections. The client no longer polls - // or publishes — the draft reaches 'ready' server-side and the user - // publishes it later from the Drafts tab. - draft, err := s.createLivestreamDraft(ctx, session.DID, uploadID, ls) if err != nil { return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) }