mirror of
https://github.com/bitwarden/server
synced 2026-01-03 09:03:44 +00:00
[PM-20452] - Offloading Stripe Update (#6034)
* Adding job to update stripe subscriptions and increment seat count when inviting a user. * Updating name * Added ef migrations * Fixing script * Fixing procedures. Added repo tests. * Fixed set stored procedure. Fixed parameter name. * Added tests for database calls and updated stored procedures * Fixed build for sql file. * fixing sproc * File is nullsafe * Adding view to select from instead of table. * Updating UpdateSubscriptionStatus to use a CTE and do all the updates in 1 statement. * Setting revision date when incrementing seat count * Added feature flag check for the background job. * Fixing nullable property. * Removing new table and just adding the column to org. Updating to query and command. Updated tests. * Adding migration script rename * Add SyncSeats to Org.sql def * Adding contraint name * Removing old table files. * Added tests * Upped the frequency to be at the top of every 3rd hour. * Updating error message. * Removing extension method * Changed to GuidIdArray * Added xml doc and switched class to record
This commit is contained in:
@@ -25,7 +25,6 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
|
||||
public class InviteOrganizationUsersCommand(IEventService eventService,
|
||||
IOrganizationUserRepository organizationUserRepository,
|
||||
IInviteUsersValidator inviteUsersValidator,
|
||||
IPaymentService paymentService,
|
||||
IOrganizationRepository organizationRepository,
|
||||
IApplicationCacheService applicationCacheService,
|
||||
IMailService mailService,
|
||||
@@ -190,12 +189,6 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
|
||||
{
|
||||
if (validatedResult.Value.PasswordManagerSubscriptionUpdate is { Seats: > 0, SeatsRequiredToAdd: > 0 })
|
||||
{
|
||||
|
||||
|
||||
await paymentService.AdjustSeatsAsync(organization,
|
||||
validatedResult.Value.InviteOrganization.Plan,
|
||||
validatedResult.Value.PasswordManagerSubscriptionUpdate.Seats.Value);
|
||||
|
||||
organization.Seats = (short?)validatedResult.Value.PasswordManagerSubscriptionUpdate.Seats;
|
||||
|
||||
await organizationRepository.ReplaceAsync(organization);
|
||||
@@ -297,13 +290,14 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
|
||||
{
|
||||
if (validatedResult.Value.PasswordManagerSubscriptionUpdate is { SeatsRequiredToAdd: > 0, UpdatedSeatTotal: > 0 })
|
||||
{
|
||||
await paymentService.AdjustSeatsAsync(organization,
|
||||
validatedResult.Value.InviteOrganization.Plan,
|
||||
validatedResult.Value.PasswordManagerSubscriptionUpdate.UpdatedSeatTotal.Value);
|
||||
await organizationRepository.IncrementSeatCountAsync(
|
||||
organization.Id,
|
||||
validatedResult.Value.PasswordManagerSubscriptionUpdate.SeatsRequiredToAdd,
|
||||
validatedResult.Value.PerformedAt.UtcDateTime);
|
||||
|
||||
organization.Seats = (short?)validatedResult.Value.PasswordManagerSubscriptionUpdate.UpdatedSeatTotal;
|
||||
organization.Seats = validatedResult.Value.PasswordManagerSubscriptionUpdate.UpdatedSeatTotal;
|
||||
organization.SyncSeats = true;
|
||||
|
||||
await organizationRepository.ReplaceAsync(organization); // could optimize this with only a property update
|
||||
await applicationCacheService.UpsertOrganizationAbilityAsync(organization);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
// FIXME: Update this file to be null safe and then delete the line below
|
||||
#nullable disable
|
||||
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Validation.PasswordManager;
|
||||
using Bit.Core.AdminConsole.Utilities.Errors;
|
||||
using Bit.Core.AdminConsole.Utilities.Validation;
|
||||
|
||||
Reference in New Issue
Block a user