[messaging/calendar] cron jobs can run regardless of sub status if billing is disabled (#5218)
## Context Messaging and calendar cron jobs are only working for workspace that have sub status different than incomplete, this is because currently this is the simplest way to know if a user is onboarded. This should not be the source of truth and this will be updated in a later version. In the meantime, to make self-hosting easier, we are adding an extra check on IS_BILLING_ENABLED env var since sub status is not relevant for people not using billing.
This commit is contained in:
@ -12,6 +12,7 @@ import {
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
|
||||
import { WorkspaceGoogleCalendarSyncService } from 'src/modules/calendar/services/workspace-google-calendar-sync/workspace-google-calendar-sync.service';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
|
||||
@ -23,14 +24,17 @@ export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
|
||||
@InjectRepository(FeatureFlagEntity, 'core')
|
||||
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
|
||||
private readonly workspaceGoogleCalendarSyncService: WorkspaceGoogleCalendarSyncService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
async handle(): Promise<void> {
|
||||
const workspaceIds = (
|
||||
await this.workspaceRepository.find({
|
||||
where: {
|
||||
subscriptionStatus: In(['active', 'trialing', 'past_due']),
|
||||
},
|
||||
where: this.environmentService.get('IS_BILLING_ENABLED')
|
||||
? {
|
||||
subscriptionStatus: In(['active', 'trialing', 'past_due']),
|
||||
}
|
||||
: {},
|
||||
select: ['id'],
|
||||
})
|
||||
).map((workspace) => workspace.id);
|
||||
|
||||
Reference in New Issue
Block a user