UpdateSubscriptionJob should not be enqueued if billing is not enabled (#5007)
## Context Adding this check to avoid enqueuing this job and following return-early good practice ## Test Without IS_BILLING_ENABLED env set <img width="565" alt="Screenshot 2024-04-17 at 15 31 12" src="https://github.com/twentyhq/twenty/assets/1834158/fcc43ce0-4455-4c4a-9889-02d99f0cd519"> With IS_BILLING_ENABLED env set <img width="581" alt="Screenshot 2024-04-17 at 15 32 28" src="https://github.com/twentyhq/twenty/assets/1834158/dc9756bd-2f6b-49bd-8897-84b6d8e09d56">
This commit is contained in:
@ -9,12 +9,14 @@ import {
|
||||
UpdateSubscriptionJob,
|
||||
UpdateSubscriptionJobData,
|
||||
} from 'src/engine/core-modules/billing/jobs/update-subscription.job';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class BillingWorkspaceMemberListener {
|
||||
constructor(
|
||||
@Inject(MessageQueue.billingQueue)
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
@OnEvent('workspaceMember.created')
|
||||
@ -22,6 +24,10 @@ export class BillingWorkspaceMemberListener {
|
||||
async handleCreateOrDeleteEvent(
|
||||
payload: ObjectRecordCreateEvent<WorkspaceMemberObjectMetadata>,
|
||||
) {
|
||||
if (!this.environmentService.get('IS_BILLING_ENABLED')) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.messageQueueService.add<UpdateSubscriptionJobData>(
|
||||
UpdateSubscriptionJob.name,
|
||||
{ workspaceId: payload.workspaceId },
|
||||
|
||||
Reference in New Issue
Block a user