Skip to content

Commit

Permalink
🐛 Fix handleTokenRefresh tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mit-27 committed May 13, 2024
1 parent c3a2c05 commit d30ad3e
Showing 1 changed file with 61 additions and 9 deletions.
70 changes: 61 additions & 9 deletions packages/api/src/@core/tasks/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import { Cron, CronExpression } from '@nestjs/schedule';
import { PrismaService } from '../prisma/prisma.service';
import { CrmConnectionsService } from '../connections/crm/services/crm.connection.service';
import { LoggerService } from '@@core/logger/logger.service';
import { ProviderVertical } from '@panora/shared';
import { AccountingConnectionsService } from '@@core/connections/accounting/services/accounting.connection.service';
import { MarketingAutomationConnectionsService } from '@@core/connections/marketingautomation/services/marketingautomation.connection.service';
import { TicketingConnectionsService } from '@@core/connections/ticketing/services/ticketing.connection.service';

@Injectable()
export class TasksService implements OnModuleInit {
constructor(
private prisma: PrismaService,
private crmConnectionsService: CrmConnectionsService,
private readonly crmConnectionsService: CrmConnectionsService,
private readonly ticketingConnectionsService: TicketingConnectionsService,
private readonly accountingConnectionsService: AccountingConnectionsService,
private readonly marketingAutomationConnectionsService: MarketingAutomationConnectionsService,
private logger: LoggerService,
) {}
) { }

onModuleInit() {
this.handleCron();
Expand All @@ -34,13 +41,58 @@ export class TasksService implements OnModuleInit {
if (connection.refresh_token) {
const account_url =
connection.provider_slug == 'zoho' ? connection.account_url : '';
await this.crmConnectionsService.handleCRMTokensRefresh(
connection.id_connection,
connection.provider_slug,
connection.refresh_token,
connection.id_project,
account_url,
);

switch (connection.vertical) {
case ProviderVertical.CRM:
await this.crmConnectionsService.handleCRMTokensRefresh(
connection.id_connection,
connection.provider_slug,
connection.refresh_token,
connection.id_project,
account_url,
);
break;

case ProviderVertical.ATS:
break;

case ProviderVertical.Accounting:
this.accountingConnectionsService.handleAccountingTokensRefresh(
connection.id_connection,
connection.provider_slug,
connection.refresh_token,
connection.id_project,
account_url,
);
break;

case ProviderVertical.FileStorage:
break;

case ProviderVertical.HRIS:
break;

case ProviderVertical.MarketingAutomation:
this.marketingAutomationConnectionsService.handleMarketingAutomationTokensRefresh(
connection.id_connection,
connection.provider_slug,
connection.refresh_token,
connection.id_project,
account_url,
);
break;

case ProviderVertical.Ticketing:
this.ticketingConnectionsService.handleTicketingTokensRefresh(
connection.id_connection,
connection.provider_slug,
connection.refresh_token,
connection.id_project,
account_url,
);
break;
}

}
}
}
Expand Down

0 comments on commit d30ad3e

Please sign in to comment.