Scheduling infrastructure for absolutely everyone.
chore: use trigger.dev task to ensure default calendars (#27556)
Morganb5eda9c57eaf
diff --git a/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts b/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.tsindex 40ece00996b..2b312dbdcd3 100644--- a/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts+++ b/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts@@ -118,6 +118,22 @@ export class OrganizationsDelegationCredentialService {const results = await Promise.allSettled(delegatedUserProfiles.map(async (profile) => {if (profile.userId) {+ if (this.configService.get("enableAsyncTasker")) {+ this.logger.log(`Adding default calendar job for user with id: ${profile.userId}`);+ await this.calendarsTasker.dispatch(+ "ensureDefaultCalendars",+ {+ userId: profile.userId,+ },+ {+ idempotencyKey: `${DEFAULT_CALENDARS_JOB}_${profile.userId}`,+ idempotencyKeyTTL: "1h",+ tags: [`${DEFAULT_CALENDARS_JOB}_${profile.userId}`],+ }+ );+ return;+ }+const job = await this.calendarsQueue.getJob(`${DEFAULT_CALENDARS_JOB}_${profile.userId}`);if (job) {await job.remove();