fix: temporarily disable sms/whatsapp to attendee workflow action (#10485)

* disable sms and whatsapp to attendee

* fix type error

* fix prisma enum imports

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Carina Wollendorfer 2023-07-31 13:45:48 -04:00 committed by GitHub
parent 9498ad4916
commit fcd8de43d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

View File

@ -134,7 +134,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
);
}
if (message?.length && message?.length > 0 && sendTo) {
if (
message?.length &&
message?.length > 0 &&
sendTo &&
reminder.workflowStep.action !== WorkflowActions.SMS_ATTENDEE
) {
const scheduledSMS = await twilio.scheduleSMS(sendTo, message, reminder.scheduledDate, senderID);
await prisma.workflowReminder.update({

View File

@ -1,11 +1,11 @@
/* Schedule any workflow reminder that falls within 7 days for WHATSAPP */
import { WorkflowActions, WorkflowMethods } from "@prisma/client";
import type { NextApiRequest, NextApiResponse } from "next";
import dayjs from "@calcom/dayjs";
import { defaultHandler } from "@calcom/lib/server";
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
import prisma from "@calcom/prisma";
import { WorkflowActions, WorkflowMethods } from "@calcom/prisma/enums";
import { getWhatsappTemplateFunction } from "../lib/actionHelperFunctions";
import * as twilio from "../lib/reminders/smsProviders/twilioProvider";
@ -90,7 +90,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
userName
);
if (message?.length && message?.length > 0 && sendTo) {
if (
message?.length &&
message?.length > 0 &&
sendTo &&
reminder.workflowStep.action !== WorkflowActions.WHATSAPP_ATTENDEE
) {
const scheduledSMS = await twilio.scheduleSMS(sendTo, message, reminder.scheduledDate, "", true);
await prisma.workflowReminder.update({

View File

@ -136,7 +136,7 @@ export const scheduleSMSReminder = async (
// Allows debugging generated email content without waiting for sendgrid to send emails
log.debug(`Sending sms for trigger ${triggerEvent}`, message);
if (message.length > 0 && reminderPhone && isNumberVerified) {
if (message.length > 0 && reminderPhone && isNumberVerified && action !== WorkflowActions.SMS_ATTENDEE) {
//send SMS when event is booked/cancelled/rescheduled
if (
triggerEvent === WorkflowTriggerEvents.NEW_EVENT ||

View File

@ -1,9 +1,14 @@
import type { TimeUnit } from "@prisma/client";
import { WorkflowTriggerEvents, WorkflowTemplates, WorkflowActions, WorkflowMethods } from "@prisma/client";
import dayjs from "@calcom/dayjs";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import {
WorkflowTriggerEvents,
WorkflowTemplates,
WorkflowActions,
WorkflowMethods,
} from "@calcom/prisma/enums";
import * as twilio from "./smsProviders/twilioProvider";
import type { BookingInfo, timeUnitLowerCase } from "./smsReminderManager";
@ -135,7 +140,12 @@ export const scheduleWhatsappReminder = async (
// Allows debugging generated whatsapp content without waiting for twilio to send whatsapp messages
log.debug(`Sending Whatsapp for trigger ${triggerEvent}`, message);
if (message.length > 0 && reminderPhone && isNumberVerified) {
if (
message.length > 0 &&
reminderPhone &&
isNumberVerified &&
action !== WorkflowActions.WHATSAPP_ATTENDEE
) {
//send WHATSAPP when event is booked/cancelled/rescheduled
if (
triggerEvent === WorkflowTriggerEvents.NEW_EVENT ||