mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-26 13:31:45 +03:00
[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:
parent
7c605fc2f9
commit
f512049381
@ -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);
|
||||
|
@ -11,6 +11,7 @@ import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repos
|
||||
import { MessageChannelRepository } from 'src/modules/messaging/repositories/message-channel.repository';
|
||||
import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
|
||||
import { GmailFetchMessageContentFromCacheService } from 'src/modules/messaging/services/gmail-fetch-message-content-from-cache/gmail-fetch-message-content-from-cache.service';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class GmailFetchMessagesFromCacheCronJob
|
||||
@ -24,14 +25,17 @@ export class GmailFetchMessagesFromCacheCronJob
|
||||
@InjectObjectMetadataRepository(MessageChannelObjectMetadata)
|
||||
private readonly messageChannelRepository: MessageChannelRepository,
|
||||
private readonly gmailFetchMessageContentFromCacheService: GmailFetchMessageContentFromCacheService,
|
||||
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);
|
||||
|
@ -16,6 +16,7 @@ import { MessageQueueService } from 'src/engine/integrations/message-queue/servi
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { MessageChannelRepository } from 'src/modules/messaging/repositories/message-channel.repository';
|
||||
import { MessageChannelObjectMetadata } from 'src/modules/messaging/standard-objects/message-channel.object-metadata';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class GmailPartialSyncCronJob implements MessageQueueJob<undefined> {
|
||||
@ -30,14 +31,17 @@ export class GmailPartialSyncCronJob implements MessageQueueJob<undefined> {
|
||||
private readonly messageQueueService: MessageQueueService,
|
||||
@InjectObjectMetadataRepository(MessageChannelObjectMetadata)
|
||||
private readonly messageChannelRepository: MessageChannelRepository,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user