Implement billing status notification and enhance user management integration
- Added `NotifyBillingStatusChangedAsync` method to `IRealtimeNotifier` for notifying clients about changes in billing status. - Updated `BillingConfigResumer` to call the new notification method after modifying billing configurations, ensuring users receive real-time updates. - Enhanced `ListUsersQueryHandler` to include a `BillingPendingReview` property in `UserSummaryDto`, indicating if a user has a pending payment request awaiting confirmation. - Refactored various command handlers to utilize `AdvisoryLock` for managing concurrent requests, preventing race conditions in billing operations. - Updated tests to cover new notification behaviors and ensure proper functionality in billing status management.
This commit is contained in:
@@ -80,4 +80,42 @@ public class InboundTests
|
||||
Assert.False(inbound.IsAvailable);
|
||||
Assert.False(inbound.IsPublished);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateFromRemote_AfterMarkUnavailable_RestoresIsAvailable()
|
||||
{
|
||||
// Инбаунд пропадал с ноды, потом снова появился при следующей синхронизации — без сброса
|
||||
// IsAvailable оставался бы недоступным навсегда, хотя реально снова опубликован на панели.
|
||||
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Old", 443);
|
||||
inbound.MarkUnavailable();
|
||||
|
||||
inbound.UpdateFromRemote(VpnProtocol.Vless, "New", 443);
|
||||
|
||||
Assert.True(inbound.IsAvailable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Publish_AfterMarkUnavailable_RestoresIsAvailable()
|
||||
{
|
||||
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Germany", 443);
|
||||
inbound.MarkUnavailable();
|
||||
|
||||
inbound.Publish("Germany", [Guid.NewGuid()]);
|
||||
|
||||
Assert.True(inbound.IsAvailable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveAllowedRole_RemovesOnlyMatchingRole()
|
||||
{
|
||||
var inbound = Inbound.FromRemote(Guid.NewGuid(), "12", VpnProtocol.Vless, "Germany", 443);
|
||||
var roleId = Guid.NewGuid();
|
||||
var otherRoleId = Guid.NewGuid();
|
||||
inbound.Publish("Germany", [roleId, otherRoleId]);
|
||||
|
||||
inbound.RemoveAllowedRole(roleId);
|
||||
|
||||
Assert.DoesNotContain(roleId, inbound.AllowedRoleIds);
|
||||
Assert.Contains(otherRoleId, inbound.AllowedRoleIds);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user