mirror of
https://github.com/bitwarden/server
synced 2026-01-19 08:53:57 +00:00
[PM-12491] Create Organization disable command (#5348)
* Add command interface and implementation for disabling organizations * Register organization disable command for dependency injection * Add unit tests for OrganizationDisableCommand * Refactor subscription handlers to use IOrganizationDisableCommand for disabling organizations * Remove DisableAsync method from IOrganizationService and its implementation in OrganizationService * Remove IOrganizationService dependency from SubscriptionDeletedHandler * Remove commented TODO for sending email to owners in OrganizationDisableCommand
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Bit.Billing.Constants;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Organizations.Interfaces;
|
||||
using Bit.Core.Services;
|
||||
using Event = Stripe.Event;
|
||||
namespace Bit.Billing.Services.Implementations;
|
||||
@@ -6,20 +7,20 @@ namespace Bit.Billing.Services.Implementations;
|
||||
public class SubscriptionDeletedHandler : ISubscriptionDeletedHandler
|
||||
{
|
||||
private readonly IStripeEventService _stripeEventService;
|
||||
private readonly IOrganizationService _organizationService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IStripeEventUtilityService _stripeEventUtilityService;
|
||||
private readonly IOrganizationDisableCommand _organizationDisableCommand;
|
||||
|
||||
public SubscriptionDeletedHandler(
|
||||
IStripeEventService stripeEventService,
|
||||
IOrganizationService organizationService,
|
||||
IUserService userService,
|
||||
IStripeEventUtilityService stripeEventUtilityService)
|
||||
IStripeEventUtilityService stripeEventUtilityService,
|
||||
IOrganizationDisableCommand organizationDisableCommand)
|
||||
{
|
||||
_stripeEventService = stripeEventService;
|
||||
_organizationService = organizationService;
|
||||
_userService = userService;
|
||||
_stripeEventUtilityService = stripeEventUtilityService;
|
||||
_organizationDisableCommand = organizationDisableCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +45,7 @@ public class SubscriptionDeletedHandler : ISubscriptionDeletedHandler
|
||||
subscription.CancellationDetails.Comment != providerMigrationCancellationComment &&
|
||||
!subscription.CancellationDetails.Comment.Contains(addedToProviderCancellationComment))
|
||||
{
|
||||
await _organizationService.DisableAsync(organizationId.Value, subscription.CurrentPeriodEnd);
|
||||
await _organizationDisableCommand.DisableAsync(organizationId.Value, subscription.CurrentPeriodEnd);
|
||||
}
|
||||
else if (userId.HasValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user