Skip to content

Commit 0b977e6

Browse files
fix: exclude opt out message from body (calcom#22100)
* fix: exclude opt out * Update packages/features/ee/workflows/api/scheduleSMSReminders.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent 979e1fd commit 0b977e6

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/features/ee/workflows/api/scheduleSMSReminders.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export async function handler(req: NextRequest) {
157157
}
158158

159159
if (message?.length && message?.length > 0 && sendTo) {
160+
const smsMessageWithoutOptOut = message;
161+
160162
if (process.env.TWILIO_OPT_OUT_ENABLED === "true") {
161163
message = await WorkflowOptOutService.addOptOutMessage(message, locale || "en");
162164
}
@@ -167,6 +169,7 @@ export async function handler(req: NextRequest) {
167169
body: message,
168170
scheduledDate: reminder.scheduledDate,
169171
sender: senderID,
172+
bodyWithoutOptOut: smsMessageWithoutOptOut,
170173
bookingUid: reminder.booking.uid,
171174
userId,
172175
teamId,

packages/features/ee/workflows/lib/reminders/messageDispatcher.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export async function sendSmsOrFallbackEmail(props: {
1414
phoneNumber: string;
1515
body: string;
1616
sender: string;
17+
bodyWithoutOptOut?: string;
1718
bookingUid?: string | null;
1819
userId?: number | null;
1920
teamId?: number | null;
@@ -40,7 +41,7 @@ export async function sendSmsOrFallbackEmail(props: {
4041
await sendOrScheduleWorkflowEmails({
4142
to: [fallbackData.email],
4243
subject: fallbackData.t("notification_about_your_booking"),
43-
html: twilioData.body,
44+
html: twilioData.bodyWithoutOptOut || twilioData.body,
4445
replyTo: fallbackData.replyTo,
4546
});
4647
}
@@ -60,6 +61,7 @@ export async function scheduleSmsOrFallbackEmail(props: {
6061
body: string;
6162
scheduledDate: Date;
6263
sender: string;
64+
bodyWithoutOptOut?: string;
6365
bookingUid?: string | null;
6466
userId?: number | null;
6567
teamId?: number | null;
@@ -96,7 +98,7 @@ export async function scheduleSmsOrFallbackEmail(props: {
9698
await sendOrScheduleWorkflowEmails({
9799
to: [fallbackData.email],
98100
subject: fallbackData.t("notification_about_your_booking"),
99-
html: twilioData.body,
101+
html: twilioData.bodyWithoutOptOut || twilioData.body,
100102
replyTo: fallbackData.replyTo,
101103
sendAt: twilioData.scheduledDate,
102104
referenceUid: reminder.uuid || undefined,

packages/features/ee/workflows/lib/reminders/smsReminderManager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ export const scheduleSMSReminder = async (args: ScheduleTextReminderArgs) => {
176176
}
177177

178178
if (smsMessage.length > 0) {
179+
const smsMessageWithoutOptOut = smsMessage;
180+
179181
if (process.env.TWILIO_OPT_OUT_ENABLED === "true") {
180182
smsMessage = await WorkflowOptOutService.addOptOutMessage(
181183
smsMessage,
@@ -196,6 +198,7 @@ export const scheduleSMSReminder = async (args: ScheduleTextReminderArgs) => {
196198
phoneNumber: reminderPhone,
197199
body: smsMessage,
198200
sender: senderID,
201+
bodyWithoutOptOut: smsMessageWithoutOptOut,
199202
bookingUid: evt.uid,
200203
userId,
201204
teamId,

0 commit comments

Comments
 (0)