Update cleaning suspended workspace job (#9999)
- split workspace metadata deletion into multiple queries - delete all subscriptions when workspace is deleted --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@ -106,7 +106,7 @@ export class BillingSubscriptionService {
|
||||
return billingSubscriptionItem;
|
||||
}
|
||||
|
||||
async deleteSubscription(workspaceId: string) {
|
||||
async deleteSubscriptions(workspaceId: string) {
|
||||
const subscriptionToCancel =
|
||||
await this.getCurrentBillingSubscriptionOrThrow({
|
||||
workspaceId,
|
||||
@ -116,8 +116,8 @@ export class BillingSubscriptionService {
|
||||
await this.stripeSubscriptionService.cancelSubscription(
|
||||
subscriptionToCancel.stripeSubscriptionId,
|
||||
);
|
||||
await this.billingSubscriptionRepository.delete(subscriptionToCancel.id);
|
||||
}
|
||||
await this.billingSubscriptionRepository.delete({ workspaceId });
|
||||
}
|
||||
|
||||
async handleUnpaidInvoices(data: Stripe.SetupIntentSucceededEvent.Data) {
|
||||
|
||||
@ -184,7 +184,7 @@ export class WorkspaceService extends TypeOrmQueryService<Workspace> {
|
||||
await this.userWorkspaceRepository.delete({ workspaceId: id });
|
||||
|
||||
if (this.billingService.isBillingEnabled()) {
|
||||
await this.billingSubscriptionService.deleteSubscription(workspace.id);
|
||||
await this.billingSubscriptionService.deleteSubscriptions(workspace.id);
|
||||
}
|
||||
|
||||
await this.workspaceManagerService.delete(id);
|
||||
|
||||
Reference in New Issue
Block a user