chore: use trigger.dev task to ensure default calendars (#27556)
This commit is contained in:
+16
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user