This commit is contained in:
@ -102,7 +102,18 @@ public class NostrController : Controller
|
|||||||
{
|
{
|
||||||
var pubkey = GetPubKey();
|
var pubkey = GetPubKey();
|
||||||
if (string.IsNullOrEmpty(pubkey)) return Unauthorized();
|
if (string.IsNullOrEmpty(pubkey)) return Unauthorized();
|
||||||
|
|
||||||
|
// 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);
|
await _userService.SetStreamInfoDefaults(pubkey, req);
|
||||||
|
}
|
||||||
|
|
||||||
return Accepted();
|
return Accepted();
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,8 @@ public class PlaylistController : Controller
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var streamManager = await _streamManagerFactory.ForCurrentStream(pubkey);
|
var streamManager = await _streamManagerFactory.ForCurrentStream(pubkey);
|
||||||
|
if (streamManager == null)
|
||||||
|
return NotFound();
|
||||||
var userStream = streamManager.GetStream();
|
var userStream = streamManager.GetStream();
|
||||||
return Redirect($"stream/{userStream.Id}.m3u8");
|
return Redirect($"stream/{userStream.Id}.m3u8");
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public class StreamManagerFactory
|
|||||||
return new NostrStreamManager(_loggerFactory.CreateLogger<NostrStreamManager>(), ctx, _serviceProvider);
|
return new NostrStreamManager(_loggerFactory.CreateLogger<NostrStreamManager>(), ctx, _serviceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IStreamManager> ForCurrentStream(string pubkey)
|
public async Task<IStreamManager?> ForCurrentStream(string pubkey)
|
||||||
{
|
{
|
||||||
var stream = await _db.Streams
|
var stream = await _db.Streams
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
@ -147,7 +147,8 @@ public class StreamManagerFactory
|
|||||||
.Include(a => a.StreamKey)
|
.Include(a => a.StreamKey)
|
||||||
.FirstOrDefaultAsync(a => a.PubKey.Equals(pubkey) && a.State == UserStreamState.Live);
|
.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
|
var ctx = new StreamManagerContext
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user