diff --git a/NostrStreamer/Controllers/NostrController.cs b/NostrStreamer/Controllers/NostrController.cs index 0674e4a..2b3a551 100644 --- a/NostrStreamer/Controllers/NostrController.cs +++ b/NostrStreamer/Controllers/NostrController.cs @@ -102,7 +102,18 @@ public class NostrController : Controller { var pubkey = GetPubKey(); if (string.IsNullOrEmpty(pubkey)) return Unauthorized(); - await _userService.SetStreamInfoDefaults(pubkey, req); + + // patch current event if specified + if (req.Id != null) + { + await _userService.UpdateStreamInfo(pubkey, req); + var stream = await _streamManagerFactory.ForStream(req.Id.Value); + await stream.UpdateEvent(); + } + else + { + await _userService.SetStreamInfoDefaults(pubkey, req); + } return Accepted(); } diff --git a/NostrStreamer/Controllers/PlaylistController.cs b/NostrStreamer/Controllers/PlaylistController.cs index 6061278..0b21fc5 100644 --- a/NostrStreamer/Controllers/PlaylistController.cs +++ b/NostrStreamer/Controllers/PlaylistController.cs @@ -100,6 +100,8 @@ public class PlaylistController : Controller try { var streamManager = await _streamManagerFactory.ForCurrentStream(pubkey); + if (streamManager == null) + return NotFound(); var userStream = streamManager.GetStream(); return Redirect($"stream/{userStream.Id}.m3u8"); } diff --git a/NostrStreamer/Services/StreamManager/StreamManagerFactory.cs b/NostrStreamer/Services/StreamManager/StreamManagerFactory.cs index 6137591..1539fce 100644 --- a/NostrStreamer/Services/StreamManager/StreamManagerFactory.cs +++ b/NostrStreamer/Services/StreamManager/StreamManagerFactory.cs @@ -138,7 +138,7 @@ public class StreamManagerFactory return new NostrStreamManager(_loggerFactory.CreateLogger(), ctx, _serviceProvider); } - public async Task ForCurrentStream(string pubkey) + public async Task ForCurrentStream(string pubkey) { var stream = await _db.Streams .AsNoTracking() @@ -147,7 +147,8 @@ public class StreamManagerFactory .Include(a => a.StreamKey) .FirstOrDefaultAsync(a => a.PubKey.Equals(pubkey) && a.State == UserStreamState.Live); - if (stream == default) throw new Exception("No live stream"); + if (stream == null) + return null; var ctx = new StreamManagerContext {