diff --git a/apps/api/v2/package.json b/apps/api/v2/package.json index 119d5e7f42..8414f5aba0 100644 --- a/apps/api/v2/package.json +++ b/apps/api/v2/package.json @@ -38,7 +38,7 @@ "@axiomhq/winston": "^1.2.0", "@calcom/platform-constants": "*", "@calcom/platform-enums": "*", - "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.354", + "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.356", "@calcom/platform-types": "*", "@calcom/platform-utils": "*", "@calcom/prisma": "*", diff --git a/packages/features/ee/workflows/lib/reminders/reminderScheduler.ts b/packages/features/ee/workflows/lib/reminders/reminderScheduler.ts index 58e21674a2..9e2f28e401 100644 --- a/packages/features/ee/workflows/lib/reminders/reminderScheduler.ts +++ b/packages/features/ee/workflows/lib/reminders/reminderScheduler.ts @@ -10,6 +10,7 @@ import * as twilio from "@calcom/features/ee/workflows/lib/reminders/providers/t import type { Workflow, WorkflowStep } from "@calcom/features/ee/workflows/lib/types"; import { checkSMSRateLimit } from "@calcom/lib/checkRateLimitAndThrowError"; import { SENDER_NAME } from "@calcom/lib/constants"; +import { formatCalEventExtended } from "@calcom/lib/formatCalendarEvent"; import { withReporting } from "@calcom/lib/sentryWrapper"; import { getTranslation } from "@calcom/lib/server/i18n"; import prisma from "@calcom/prisma"; @@ -53,7 +54,7 @@ const processWorkflowStep = async ( step: WorkflowStep, { smsReminderNumber, - calendarEvent: evt, + calendarEvent, emailAttendeeSendToOverride, hideBranding, seatReferenceUid, @@ -61,6 +62,8 @@ const processWorkflowStep = async ( ) => { if (!step?.verifiedAt) return; + const evt = formatCalEventExtended(calendarEvent); + if (isSMSOrWhatsappAction(step.action)) { await checkSMSRateLimit({ identifier: `sms:${workflow.teamId ? "team:" : "user:"}${workflow.teamId || workflow.userId}`, diff --git a/packages/lib/formatCalendarEvent.ts b/packages/lib/formatCalendarEvent.ts index 8c177dc74b..bfdd36301d 100644 --- a/packages/lib/formatCalendarEvent.ts +++ b/packages/lib/formatCalendarEvent.ts @@ -1,10 +1,11 @@ // eslint-disable-next-line no-restricted-imports import { cloneDeep } from "lodash"; +import type { ExtendedCalendarEvent } from "@calcom/ee/workflows/lib/reminders/reminderScheduler"; import type { CalendarEvent } from "@calcom/types/Calendar"; // format CalEvent to remove platformClientId from email addresses -const formatClientIdFromEmails = (calEvent: CalendarEvent, clientId: string) => { +const formatClientIdFromEmails = (calEvent: CalendarEvent | ExtendedCalendarEvent, clientId: string) => { const attendees = calEvent.attendees.map((attendee) => ({ ...attendee, email: attendee.email.replace(`+${clientId}`, ""), @@ -25,3 +26,13 @@ export const formatCalEvent = (calEvent: CalendarEvent) => { return clonedEvent; }; + +export const formatCalEventExtended = (calEvent: ExtendedCalendarEvent) => { + const clonedEvent = cloneDeep(calEvent); + if (clonedEvent.platformClientId) { + const [attendees, organizer] = formatClientIdFromEmails(clonedEvent, clonedEvent.platformClientId); + Object.assign(clonedEvent, { attendees, organizer }); + } + + return clonedEvent; +}; diff --git a/yarn.lock b/yarn.lock index d98a10afbc..d5570aaee6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2715,7 +2715,7 @@ __metadata: "@axiomhq/winston": ^1.2.0 "@calcom/platform-constants": "*" "@calcom/platform-enums": "*" - "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.354" + "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.356" "@calcom/platform-types": "*" "@calcom/platform-utils": "*" "@calcom/prisma": "*" @@ -3775,13 +3775,13 @@ __metadata: languageName: unknown linkType: soft -"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.354": - version: 0.0.354 - resolution: "@calcom/platform-libraries@npm:0.0.354" +"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.356": + version: 0.0.356 + resolution: "@calcom/platform-libraries@npm:0.0.356" dependencies: "@calcom/features": "*" "@calcom/lib": "*" - checksum: 672e2567bf95692152b873688ff1a2e03401d622c3cb8410d518138893288776670d1dc5fdbe89a08d3326c3d41c081f0b70cf9f7bdc97b9a5229b9c80a2f817 + checksum: dabce8a4add6c8082f06168ce9fbfef9be258f8ac3c60cb81e1985b4b49e2503f0f539dda9faf371bd1c79133419aed36d0ff849b6a2ecca77e7854752d8c97d languageName: node linkType: hard