fix: missing userPrimaryEmail in workflows (#13875)

* fix: missing userPrimaryEmail in workflows

* chore

* fix: type err
This commit is contained in:
Udit Takkar
2024-02-27 09:17:34 -05:00
committed by GitHub
parent 27c25e1f95
commit 80080dda7a
2 changed files with 5 additions and 3 deletions
@@ -116,7 +116,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
switch (reminder.workflowStep.action) {
case WorkflowActions.EMAIL_HOST:
sendTo = reminder.booking.user?.email;
sendTo = reminder.booking?.userPrimaryEmail ?? reminder.booking.user?.email;
break;
case WorkflowActions.EMAIL_ATTENDEE:
sendTo = reminder.booking.attendees[0].email;
@@ -227,7 +227,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
html: emailContent.emailBody,
batchId: batchId,
sendAt: dayjs(reminder.scheduledDate).unix(),
replyTo: reminder.booking.user?.email,
replyTo: reminder.booking?.userPrimaryEmail ?? reminder.booking.user?.email,
attachments: reminder.workflowStep.includeCalendarEvent
? [
{
@@ -297,7 +297,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
html: emailContent.emailBody,
batchId: batchId,
sendAt: dayjs(reminder.scheduledDate).unix(),
replyTo: reminder.booking.user?.email,
replyTo: reminder.booking?.userPrimaryEmail ?? reminder.booking.user?.email,
},
{ sender: reminder.workflowStep?.sender }
)
@@ -23,6 +23,7 @@ type PartialBooking =
| "responses"
| "uid"
| "attendees"
| "userPrimaryEmail"
> & { eventType: Partial<EventType> | null } & { user: Partial<User> | null })
| null;
@@ -134,6 +135,7 @@ export async function getAllUnscheduledReminders(): Promise<PartialWorkflowRemin
endTime: true,
location: true,
description: true,
userPrimaryEmail: true,
user: {
select: {
email: true,