Dont block on notification

This commit is contained in:
2024-05-08 18:59:33 +01:00
parent e852e20880
commit ae4f594394

View File

@ -84,22 +84,26 @@ public class NostrStreamManager : IStreamManager
var ev = await UpdateStreamState(UserStreamState.Live); var ev = await UpdateStreamState(UserStreamState.Live);
if (_config.DiscordLiveWebhook != default) _ = Task.Factory.StartNew(async () =>
{ {
try if (_config.DiscordLiveWebhook != default)
{ {
var npub = NostrConverter.ToBech32(_context.User.PubKey, "npub")!; try
var profile = await _nostrApi.Profile(npub); {
var name = profile?.Name ?? npub; var npub = NostrConverter.ToBech32(_context.User.PubKey, "npub")!;
var id = ev.ToIdentifier(); var profile = await _nostrApi.Profile(npub);
await _webhook.SendMessage(_config.DiscordLiveWebhook, var name = profile?.Name ?? npub;
$"{name} went live!\nhttps://zap.stream/{id.ToBech32()}"); var id = ev.ToIdentifier();
await _webhook.SendMessage(_config.DiscordLiveWebhook,
$"{name} went live!\nhttps://zap.stream/{id.ToBech32()}");
}
catch (Exception ex)
{
_logger.LogWarning("Failed to send notification {msg}", ex.Message);
}
} }
catch (Exception ex) });
{
_logger.LogWarning("Failed to send notification {msg}", ex.Message);
}
}
} }
public async Task StreamStopped() public async Task StreamStopped()