feat(server): delay subscription after invitation accepted or approved (#11992)

This commit is contained in:
liuyi
2025-04-30 14:27:47 +08:00
committed by GitHub
parent 9a721c65b5
commit 2e1bed061e
49 changed files with 1990 additions and 2694 deletions
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { OnEvent } from '../../base';
import { WorkspaceService } from '../../core/workspaces/resolvers';
import { EventBus, OnEvent } from '../../base';
import { WorkspaceService } from '../../core/workspaces';
import { Models } from '../../models';
import { SubscriptionPlan } from './types';
@@ -9,7 +9,8 @@ import { SubscriptionPlan } from './types';
export class QuotaOverride {
constructor(
private readonly workspace: WorkspaceService,
private readonly models: Models
private readonly models: Models,
private readonly event: EventBus
) {}
@OnEvent('workspace.subscription.activated')
@@ -30,7 +31,10 @@ export class QuotaOverride {
memberLimit: quantity,
}
);
await this.models.workspaceUser.refresh(workspaceId, quantity);
this.event.emit('workspace.members.allocateSeats', {
workspaceId,
quantity,
});
if (!isTeam) {
// this event will triggered when subscription is activated or changed
// we only send emails when the team workspace is activated