Leverage workspace activationStatus to decide if a workspace is activated or not (#6497)
An ACTIVE workspace is a workspace that has a complete workspaceSchema and is authorized to be browsed by users. In this PR, I'm: - introducing a new activationStatus: PENDING_CREATION (existing ACTIVE / INACTIVE) - removing workspaceService.isWorkspaceActivated (based on workspaceSchema existence which is not robust and checking activationStatus.ACTIVE instead) - removing dynamic activationStatus field on worksapce resolver (we can use the postgres column directly now that data has been migrated) - on user sign up creating the workspace in PENDING_CREATION, and on workspace activation setting it to ACTIVE - only re-activating a workspace if the current activationStatus is INACTIVE through billing webhooks (a PENDING_CREATION should stay PENDING and ACTIVE should stay ACTIVE)
This commit is contained in:
@ -284,7 +284,7 @@ export class BillingWorkspaceService {
|
||||
| Stripe.CustomerSubscriptionCreatedEvent.Data
|
||||
| Stripe.CustomerSubscriptionDeletedEvent.Data,
|
||||
) {
|
||||
const workspace = this.workspaceRepository.find({
|
||||
const workspace = await this.workspaceRepository.findOne({
|
||||
where: { id: workspaceId },
|
||||
});
|
||||
|
||||
@ -341,9 +341,10 @@ export class BillingWorkspaceService {
|
||||
}
|
||||
|
||||
if (
|
||||
data.object.status === SubscriptionStatus.Active ||
|
||||
data.object.status === SubscriptionStatus.Trialing ||
|
||||
data.object.status === SubscriptionStatus.PastDue
|
||||
(data.object.status === SubscriptionStatus.Active ||
|
||||
data.object.status === SubscriptionStatus.Trialing ||
|
||||
data.object.status === SubscriptionStatus.PastDue) &&
|
||||
workspace.activationStatus == WorkspaceActivationStatus.INACTIVE
|
||||
) {
|
||||
await this.workspaceRepository.update(workspaceId, {
|
||||
activationStatus: WorkspaceActivationStatus.ACTIVE,
|
||||
|
||||
Reference in New Issue
Block a user