-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Workflow action 'email to host' only sends to one host of team e… #14767
base: main
Are you sure you want to change the base?
Changes from 6 commits
c8b0494
8762b1a
697f352
7ac163b
e55c8d2
f9134bc
21473c4
651341e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import logger from "@calcom/lib/logger"; | |
import { defaultHandler } from "@calcom/lib/server"; | ||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat"; | ||
import prisma from "@calcom/prisma"; | ||
import { WorkflowActions, WorkflowMethods, WorkflowTemplates } from "@calcom/prisma/enums"; | ||
import { SchedulingType, WorkflowActions, WorkflowMethods, WorkflowTemplates } from "@calcom/prisma/enums"; | ||
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils"; | ||
|
||
import type { PartialWorkflowReminder } from "../lib/getWorkflowReminders"; | ||
|
@@ -119,6 +119,19 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { | |
switch (reminder.workflowStep.action) { | ||
case WorkflowActions.EMAIL_HOST: | ||
sendTo = reminder.booking?.userPrimaryEmail ?? reminder.booking.user?.email; | ||
const hosts = reminder.booking.attendees | ||
.filter((attendee) => | ||
reminder.booking?.eventType?.hosts?.some((host) => host.user.email === attendee.email) | ||
) | ||
.map((host) => host.email); | ||
const schedulingType = reminder.booking.eventType?.schedulingType; | ||
|
||
if ( | ||
hosts && | ||
(schedulingType === SchedulingType.COLLECTIVE || schedulingType === SchedulingType.ROUND_ROBIN) | ||
) { | ||
sendTo = sendTo ? [sendTo, ...hosts] : hosts; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks fine but what if user has connected a calendar. in that case we send the email and create calendar invite only on the connected calendar email address There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure wdym but that. Since user is host wouldn't he already have calendar invite? Also isn't calendar.ics being sent with the mail? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. email address in user' account could be different than connected calendar email |
||
break; | ||
case WorkflowActions.EMAIL_ATTENDEE: | ||
sendTo = reminder.booking.attendees[0].email; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of writing a new test uncommented this as this tests for receiving emails for all hosts.