Refactor onboarding user vars to be absent when user is fully onboarded (#6531)
In this PR: - take feedbacks from: https://github.com/twentyhq/twenty/pull/6530 / https://github.com/twentyhq/twenty/pull/6529 / https://github.com/twentyhq/twenty/pull/6526 / https://github.com/twentyhq/twenty/pull/6512 - refactor onboarding uservars to be absent when the user is fully onboarded: isStepComplete ==> isStepIncomplete - introduce a new workspace.activationStatus: CREATION_ONGOING I'm retesting the whole flow: - with/without BILLING - sign in with/without SSO - sign up with/without SSO - another workspaceMembers join the team - subscriptionCanceled - access to billingPortal
This commit is contained in:
@ -1,6 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import {
|
||||
Workspace,
|
||||
WorkspaceActivationStatus,
|
||||
} from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { ObjectRecordCreateEvent } from 'src/engine/integrations/event-emitter/types/object-record-create.event';
|
||||
import { ObjectRecordUpdateEvent } from 'src/engine/integrations/event-emitter/types/object-record-update.event';
|
||||
import { objectRecordChangedProperties as objectRecordUpdateEventChangedProperties } from 'src/engine/integrations/event-emitter/utils/object-record-changed-properties.util';
|
||||
@ -8,12 +15,12 @@ import { InjectMessageQueue } from 'src/engine/integrations/message-queue/decora
|
||||
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
|
||||
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
|
||||
import {
|
||||
MessageParticipantMatchParticipantJobData,
|
||||
MessageParticipantMatchParticipantJob,
|
||||
MessageParticipantMatchParticipantJobData,
|
||||
} from 'src/modules/messaging/message-participant-manager/jobs/message-participant-match-participant.job';
|
||||
import {
|
||||
MessageParticipantUnmatchParticipantJobData,
|
||||
MessageParticipantUnmatchParticipantJob,
|
||||
MessageParticipantUnmatchParticipantJobData,
|
||||
} from 'src/modules/messaging/message-participant-manager/jobs/message-participant-unmatch-participant.job';
|
||||
import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/standard-objects/workspace-member.workspace-entity';
|
||||
|
||||
@ -22,12 +29,25 @@ export class MessageParticipantWorkspaceMemberListener {
|
||||
constructor(
|
||||
@InjectMessageQueue(MessageQueue.messagingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
@InjectRepository(Workspace, 'core')
|
||||
private readonly workspaceRepository: Repository<Workspace>,
|
||||
) {}
|
||||
|
||||
@OnEvent('workspaceMember.created')
|
||||
async handleCreatedEvent(
|
||||
payload: ObjectRecordCreateEvent<WorkspaceMemberWorkspaceEntity>,
|
||||
) {
|
||||
const workspace = await this.workspaceRepository.findOneBy({
|
||||
id: payload.workspaceId,
|
||||
});
|
||||
|
||||
if (
|
||||
!workspace ||
|
||||
workspace.activationStatus !== WorkspaceActivationStatus.ACTIVE
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.properties.after.userEmail === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { AnalyticsModule } from 'src/engine/core-modules/analytics/analytics.module';
|
||||
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ObjectMetadataRepositoryModule } from 'src/engine/object-metadata-repository/object-metadata-repository.module';
|
||||
import { TwentyORMModule } from 'src/engine/twenty-orm/twenty-orm.module';
|
||||
@ -22,7 +23,7 @@ import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-o
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([FeatureFlagEntity], 'core'),
|
||||
TypeOrmModule.forFeature([FeatureFlagEntity, Workspace], 'core'),
|
||||
AnalyticsModule,
|
||||
ContactCreationManagerModule,
|
||||
WorkspaceDataSourceModule,
|
||||
|
||||
Reference in New Issue
Block a user