mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 01:22:50 -05:00
organization status changed code changes (#5113)
* organization status changed code changes Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Add the push notification to subscriptionUpdated Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * send notification using the SendPayloadToUser Signed-off-by: Cy Okeke <cokeke@bitwarden.com> * Change the implementation to send userId * Added new implementation for orgstatus sync * refactor the code and remove private methods --------- Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
@ -25,6 +25,7 @@ public class PaymentSucceededHandler : IPaymentSucceededHandler
|
||||
private readonly ICurrentContext _currentContext;
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IStripeEventUtilityService _stripeEventUtilityService;
|
||||
private readonly IPushNotificationService _pushNotificationService;
|
||||
|
||||
public PaymentSucceededHandler(
|
||||
ILogger<PaymentSucceededHandler> logger,
|
||||
@ -37,7 +38,8 @@ public class PaymentSucceededHandler : IPaymentSucceededHandler
|
||||
IUserRepository userRepository,
|
||||
IStripeEventUtilityService stripeEventUtilityService,
|
||||
IUserService userService,
|
||||
IOrganizationService organizationService)
|
||||
IOrganizationService organizationService,
|
||||
IPushNotificationService pushNotificationService)
|
||||
{
|
||||
_logger = logger;
|
||||
_stripeEventService = stripeEventService;
|
||||
@ -50,6 +52,7 @@ public class PaymentSucceededHandler : IPaymentSucceededHandler
|
||||
_stripeEventUtilityService = stripeEventUtilityService;
|
||||
_userService = userService;
|
||||
_organizationService = organizationService;
|
||||
_pushNotificationService = pushNotificationService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -140,6 +143,7 @@ public class PaymentSucceededHandler : IPaymentSucceededHandler
|
||||
|
||||
await _organizationService.EnableAsync(organizationId.Value, subscription.CurrentPeriodEnd);
|
||||
var organization = await _organizationRepository.GetByIdAsync(organizationId.Value);
|
||||
await _pushNotificationService.PushSyncOrganizationStatusAsync(organization);
|
||||
|
||||
await _referenceEventService.RaiseEventAsync(
|
||||
new ReferenceEvent(ReferenceEventType.Rebilled, organization, _currentContext)
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Bit.Billing.Constants;
|
||||
using Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.Interfaces;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Stripe;
|
||||
@ -15,6 +16,8 @@ public class SubscriptionUpdatedHandler : ISubscriptionUpdatedHandler
|
||||
private readonly IStripeFacade _stripeFacade;
|
||||
private readonly IOrganizationSponsorshipRenewCommand _organizationSponsorshipRenewCommand;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IPushNotificationService _pushNotificationService;
|
||||
private readonly IOrganizationRepository _organizationRepository;
|
||||
|
||||
public SubscriptionUpdatedHandler(
|
||||
IStripeEventService stripeEventService,
|
||||
@ -22,7 +25,9 @@ public class SubscriptionUpdatedHandler : ISubscriptionUpdatedHandler
|
||||
IOrganizationService organizationService,
|
||||
IStripeFacade stripeFacade,
|
||||
IOrganizationSponsorshipRenewCommand organizationSponsorshipRenewCommand,
|
||||
IUserService userService)
|
||||
IUserService userService,
|
||||
IPushNotificationService pushNotificationService,
|
||||
IOrganizationRepository organizationRepository)
|
||||
{
|
||||
_stripeEventService = stripeEventService;
|
||||
_stripeEventUtilityService = stripeEventUtilityService;
|
||||
@ -30,6 +35,8 @@ public class SubscriptionUpdatedHandler : ISubscriptionUpdatedHandler
|
||||
_stripeFacade = stripeFacade;
|
||||
_organizationSponsorshipRenewCommand = organizationSponsorshipRenewCommand;
|
||||
_userService = userService;
|
||||
_pushNotificationService = pushNotificationService;
|
||||
_organizationRepository = organizationRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -70,6 +77,8 @@ public class SubscriptionUpdatedHandler : ISubscriptionUpdatedHandler
|
||||
case StripeSubscriptionStatus.Active when organizationId.HasValue:
|
||||
{
|
||||
await _organizationService.EnableAsync(organizationId.Value);
|
||||
var organization = await _organizationRepository.GetByIdAsync(organizationId.Value);
|
||||
await _pushNotificationService.PushSyncOrganizationStatusAsync(organization);
|
||||
break;
|
||||
}
|
||||
case StripeSubscriptionStatus.Active:
|
||||
|
Reference in New Issue
Block a user