chore: use trigger.dev task to ensure default calendars (#27556)

This commit is contained in:
Morgan
2026-02-03 14:44:28 +05:30
committed by GitHub
parent fc3815a150
commit b5eda9c57e
@@ -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();