Refactor client update handling to support nullable parameters for name and expiration
- Updated the `UpdateClientAsync` method in `IXuiPanelGateway` to accept nullable parameters for `name` and `expiresAt`, allowing for more flexible client management without unintended modifications. - Adjusted the `BlockUserCommandHandler`, `UnblockUserCommandHandler`, and other related command handlers to utilize the new nullable parameters, ensuring that client names remain unchanged during block/unblock operations and that expiration dates are managed correctly. - Enhanced the billing and configuration handling to reflect the new logic for managing client states based on expiration rather than enabling/disabling, improving reliability in client status management. - Updated tests to cover the new behavior and ensure proper functionality across the application.
This commit is contained in:
+6
-2
@@ -167,7 +167,8 @@ public class ConfirmPaymentRequestCommandHandlerTests
|
||||
Arg.Any<string>(),
|
||||
Arg.Any<VpnProtocol>(),
|
||||
Arg.Any<string>(),
|
||||
enable: true,
|
||||
Arg.Any<bool?>(),
|
||||
Arg.Any<DateTimeOffset?>(),
|
||||
Arg.Any<CancellationToken>()
|
||||
)
|
||||
.Returns(Result.Success());
|
||||
@@ -192,6 +193,8 @@ public class ConfirmPaymentRequestCommandHandlerTests
|
||||
Assert.NotNull(expiredConfig.ExpiresAt);
|
||||
Assert.NotNull(activeConfig.ExpiresAt);
|
||||
Assert.Equal(expiredConfig.ExpiresAt, activeConfig.ExpiresAt);
|
||||
// enable: null — возврат из приостановки теперь идёт через expiresAt (новый newPaidUntil),
|
||||
// а не через переключение enable (см. IXuiPanelGateway.UpdateClientAsync).
|
||||
await _gateway
|
||||
.Received(1)
|
||||
.UpdateClientAsync(
|
||||
@@ -200,7 +203,8 @@ public class ConfirmPaymentRequestCommandHandlerTests
|
||||
"ext-1",
|
||||
VpnProtocol.Vless,
|
||||
Arg.Any<string>(),
|
||||
enable: true,
|
||||
null,
|
||||
Arg.Is<DateTimeOffset?>(d => d == expiredConfig.ExpiresAt),
|
||||
Arg.Any<CancellationToken>()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user