Prepare podcast emissions using LiveFlow

Persist scheduled emissions, expose owner-only planning controls in PostIt and publish optional presentation-only announcements on Yavsc.Org. Preserve manual broadcasting and authenticated playback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Paul Schneider 2026-11-02 14:08:22 +00:00
commit 4a5a3c8844
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
28 changed files with 5960 additions and 29 deletions

View file

@ -20,7 +20,7 @@ namespace Yavsc.Services
/// <returns></returns>
Task<bool> AcceptStream (HttpContext context, ApplicationUser user, string destDir, string fileName);
Task<PodcastResponse> CreateAsync(string ownerId, string ownerName, string title, CancellationToken ct);
Task<PodcastResponse> CreateAsync(string ownerId, string ownerName, string title, CancellationToken ct, Guid? id = null);
Task<IReadOnlyList<PodcastResponse>> ListAsync(CancellationToken ct);
Task<PodcastManifestResponse> GetAsync(Guid id, CancellationToken ct);
Task<PodcastResponse> AppendAsync(Guid id, string ownerId, int sequence,

View file

@ -48,6 +48,8 @@ namespace Yavsc.Models
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<LiveFlow>().HasIndex(f => f.PodcastId).IsUnique();
builder.Entity<LiveFlow>().Property(f => f.PublicAnnouncement).HasMaxLength(1023);
if (Database.IsNpgsql())
{
NOW_SQL = "LOCALTIMESTAMP";
@ -499,7 +501,6 @@ namespace Yavsc.Models
public DbSet<Project> Project { get; set; }
[Obsolete("use signaled flows")]
public DbSet<LiveFlow> LiveFlow { get; set; }
public DbSet<ChatRoomAccess> ChatRoomAccess { get; set; }

View file

@ -8,6 +8,14 @@ namespace Yavsc.Models.Streaming
public partial class LiveFlow : ILiveFlow {
public Guid? PodcastId { get; set; }
public DateTimeOffset? ScheduledStartAt { get; set; }
public int? PlannedDurationMinutes { get; set; }
public string PublicAnnouncement { get; set; } = string.Empty;
public DateTimeOffset? PreparedAt { get; set; }
public DateTimeOffset? StartedAt { get; set; }
public bool PodcastDeleted { get; set; }
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Display(Name="FlowIdLabel", ResourceType=typeof(LiveFlow))]
// set by the server, unique

View file

@ -41,7 +41,7 @@ public sealed class LiveProcessor : ILiveProcessor, IDisposable
throw new InvalidOperationException("Invalid Podcast storage options.");
}
public async Task<PodcastResponse> CreateAsync(string ownerId, string ownerName, string title, CancellationToken ct)
public async Task<PodcastResponse> CreateAsync(string ownerId, string ownerName, string title, CancellationToken ct, Guid? id = null)
{
if (string.IsNullOrWhiteSpace(ownerId) || string.IsNullOrWhiteSpace(title) || title.Trim().Length > 160)
throw new PodcastException(400, "Un titre de 1 a 160 caracteres et un utilisateur sont requis.");
@ -50,6 +50,12 @@ public sealed class LiveProcessor : ILiveProcessor, IDisposable
{
await LoadAsync(ct);
await ExpireAsync(ct);
if (id.HasValue && _documents.TryGetValue(id.Value, out var existing))
{
if (existing.Manifest.Podcast.OwnerId != ownerId)
throw new PodcastException(403, "Seul l'auteur peut demarrer ce podcast.");
return existing.Manifest.Podcast;
}
if (_documents.Values.Any(d => d.Manifest.Podcast.OwnerId == ownerId && d.Manifest.Podcast.State == PodcastState.Live))
throw new PodcastException(409, "Vous avez deja un direct en cours.");
if (OwnerBytes(ownerId) >= _options.MaxOwnerBytes)
@ -57,7 +63,7 @@ public sealed class LiveProcessor : ILiveProcessor, IDisposable
if (_documents.Values.Count(d => d.Manifest.Podcast.OwnerId == ownerId) >= _options.MaxOwnerPodcasts)
throw new PodcastException(413, "Nombre maximal de podcasts atteint. Supprimez un ancien replay.");
var now = _clock.GetUtcNow();
var podcast = new PodcastResponse(Guid.NewGuid(), title.Trim(), ownerId, ownerName,
var podcast = new PodcastResponse(id ?? Guid.NewGuid(), title.Trim(), ownerId, ownerName,
now, now, PodcastState.Live, 0, 0, 0);
var document = new Document(new(podcast, Array.Empty<PodcastSegmentResponse>()), Array.Empty<string>());
Directory.CreateDirectory(DirectoryFor(podcast.Id));