fix: zero balance checks
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -41,7 +41,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
|
|
||||||
public void TestCanStream()
|
public void TestCanStream()
|
||||||
{
|
{
|
||||||
if (_context.User.Balance <= 0)
|
if (_context.User.Balance < 0)
|
||||||
{
|
{
|
||||||
throw new LowBalanceException("User balance empty");
|
throw new LowBalanceException("User balance empty");
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
{
|
{
|
||||||
TestCanStream();
|
TestCanStream();
|
||||||
var fwds = new List<string>();
|
var fwds = new List<string>();
|
||||||
if (_context.UserStream.Endpoint != default)
|
if (_context.UserStream.Endpoint != null)
|
||||||
{
|
{
|
||||||
fwds.Add(
|
fwds.Add(
|
||||||
$"rtmp://127.0.0.1:1935/{_context.UserStream.Endpoint.App}/{_context.StreamKey}?vhost={_context.UserStream.Endpoint.Forward}");
|
$"rtmp://127.0.0.1:1935/{_context.UserStream.Endpoint.App}/{_context.StreamKey}?vhost={_context.UserStream.Endpoint.Forward}");
|
||||||
@ -88,7 +88,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
|
|
||||||
_ = Task.Factory.StartNew(async () =>
|
_ = Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
if (_config.DiscordLiveWebhook != default)
|
if (_config.DiscordLiveWebhook != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
{
|
{
|
||||||
const long balanceAlertThreshold = 500_000;
|
const long balanceAlertThreshold = 500_000;
|
||||||
|
|
||||||
if (_context.UserStream.Endpoint == default) return;
|
if (_context.UserStream.Endpoint == null) return;
|
||||||
var cost = (long)Math.Ceiling(_context.UserStream.Endpoint.Cost * (duration / 60d));
|
var cost = (long)Math.Ceiling(_context.UserStream.Endpoint.Cost * (duration / 60d));
|
||||||
if (cost > 0)
|
if (cost > 0)
|
||||||
{
|
{
|
||||||
@ -166,7 +166,7 @@ public class NostrStreamManager : IStreamManager
|
|||||||
_eventBuilder.BroadcastEvent(chat);
|
_eventBuilder.BroadcastEvent(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_context.User.Balance <= 0 || _context.User.IsBlocked)
|
if (_context.User.Balance < 0 || _context.User.IsBlocked)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Kicking stream due to low balance");
|
_logger.LogInformation("Kicking stream due to low balance");
|
||||||
if (!string.IsNullOrEmpty(_context.UserStream.ForwardClientId))
|
if (!string.IsNullOrEmpty(_context.UserStream.ForwardClientId))
|
||||||
|
@ -40,7 +40,7 @@ public class StreamManagerFactory
|
|||||||
|
|
||||||
if (ep == default) throw new Exception("No endpoint found");
|
if (ep == default) throw new Exception("No endpoint found");
|
||||||
|
|
||||||
if (user.Balance <= 0 && ep.Cost > 0)
|
if (user.Balance < 0)
|
||||||
{
|
{
|
||||||
throw new LowBalanceException("Cannot start stream with empty balance");
|
throw new LowBalanceException("Cannot start stream with empty balance");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user