-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fixes bug that new line is not working in workflow reminder emails #3452
Changes from all commits
0bd9735
7d1e04a
4ffbf79
6aa2b37
67b461c
c07055e
c5ad3c6
ee967fd
c4023b2
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,6 @@ import client from "@sendgrid/client"; | |
import sgMail from "@sendgrid/mail"; | ||
|
||
import dayjs from "@calcom/dayjs"; | ||
import { sendWorkflowReminderEmail } from "@calcom/emails"; | ||
import prisma from "@calcom/prisma"; | ||
import { BookingInfo, timeUnitLowerCase } from "@ee/lib/workflows/reminders/smsReminderManager"; | ||
import emailReminderTemplate from "@ee/lib/workflows/reminders/templates/emailReminderTemplate"; | ||
|
@@ -60,11 +59,17 @@ export const scheduleEmailReminder = async ( | |
const attendeeName = action === WorkflowActions.EMAIL_HOST ? evt.attendees[0].name : evt.organizer.name; | ||
const timeZone = action === WorkflowActions.EMAIL_HOST ? evt.organizer.timeZone : evt.attendees[0].timeZone; | ||
|
||
let emailContent = { | ||
emailSubject, | ||
emailBody: { | ||
text: emailBody, | ||
html: `<body style="white-space: pre-wrap;">${emailBody}</body>`, | ||
}, | ||
}; | ||
|
||
switch (template) { | ||
case WorkflowTemplates.REMINDER: | ||
const emailTemplate = emailReminderTemplate(startTime, evt.title, timeZone, attendeeName, name); | ||
emailSubject = emailTemplate.subject; | ||
emailBody = emailTemplate.body; | ||
emailContent = emailReminderTemplate(startTime, evt.title, timeZone, attendeeName, name); | ||
break; | ||
} | ||
|
||
|
@@ -73,7 +78,14 @@ export const scheduleEmailReminder = async ( | |
triggerEvent === WorkflowTriggerEvents.EVENT_CANCELLED | ||
) { | ||
try { | ||
await sendWorkflowReminderEmail(evt, sendTo, emailSubject, emailBody); | ||
await sgMail.send({ | ||
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. remove sendWorkflowReminderEmail as it is not needed and emails were sent from the organizer instead of hello@cal.com |
||
to: sendTo, | ||
from: senderEmail, | ||
subject: emailContent.emailSubject, | ||
text: emailContent.emailBody.text, | ||
html: emailContent.emailBody.html, | ||
batchId: batchIdResponse[1].batch_id, | ||
}); | ||
} catch (error) { | ||
console.log("Error sending Email"); | ||
} | ||
|
@@ -88,13 +100,9 @@ export const scheduleEmailReminder = async ( | |
await sgMail.send({ | ||
to: sendTo, | ||
from: senderEmail, | ||
subject: emailSubject, | ||
content: [ | ||
{ | ||
type: "text/html", | ||
value: emailBody, | ||
}, | ||
], | ||
subject: emailContent.emailSubject, | ||
text: emailContent.emailBody.text, | ||
html: emailContent.emailBody.html, | ||
batchId: batchIdResponse[1].batch_id, | ||
sendAt: scheduledDate.unix(), | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,25 @@ const emailReminderTemplate = ( | |
attendee: string, | ||
name: string | ||
) => { | ||
const templateSubject = `Reminder: ${eventName} at ${dayjs(startTime) | ||
const emailSubject = `Reminder: ${eventName} on ${dayjs(startTime) | ||
.tz(timeZone) | ||
.format("YYYY MMM D h:mmA")}`; | ||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.`; | ||
|
||
const templateBody = `Hi ${name},\n\nThis is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs( | ||
const templateBodyText = `Hi ${name}, this is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs( | ||
startTime | ||
) | ||
.tz(timeZone) | ||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.`; | ||
|
||
const emailContent = { subject: templateSubject, body: templateBody }; | ||
const templateBodyHtml = `<body>Hi ${name},<br><br>This is a reminder that your meeting (${eventName}) with ${attendee} is on ${dayjs( | ||
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. in html format so line breaks are actually working |
||
startTime | ||
) | ||
.tz(timeZone) | ||
.format("YYYY MMM D")} at ${dayjs(startTime).tz(timeZone).format("h:mmA")} ${timeZone}.<body>`; | ||
|
||
const emailBody = { text: templateBodyText, html: templateBodyHtml }; | ||
|
||
return emailContent; | ||
return { emailSubject, emailBody }; | ||
}; | ||
|
||
export default emailReminderTemplate; |
This file was deleted.
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.
necessary so line breaks from custom templates work