Skip to content

Commit

Permalink
fix: disable sending sms when email is present (#18632)
Browse files Browse the repository at this point in the history
* fix: disable sending sms when email is present

* fix: update test
  • Loading branch information
Udit-takkar authored Jan 13, 2025
1 parent f88a91d commit 96ff88d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,6 @@ describe("handleNewBooking", () => {
subscriberUrl: "http://my-webhook.example.com",
videoCallUrl: `${WEBAPP_URL}/video/${createdBooking.uid}`,
});

expectSMSToBeTriggered({ sms, toNumber: TEST_ATTENDEE_NUMBER });
},
timeout
);
Expand Down
7 changes: 4 additions & 3 deletions packages/sms/sms-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getSenderId } from "@calcom/features/ee/workflows/lib/alphanumericSende
import * as twilio from "@calcom/features/ee/workflows/lib/reminders/providers/twilioProvider";
import { checkSMSRateLimit } from "@calcom/lib/checkRateLimitAndThrowError";
import { SENDER_ID } from "@calcom/lib/constants";
import isSmsCalEmail from "@calcom/lib/isSmsCalEmail";
import { TimeFormat } from "@calcom/lib/timeFormat";
import prisma from "@calcom/prisma";
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
Expand Down Expand Up @@ -76,10 +77,10 @@ export default abstract class SMSManager {

async sendSMSToAttendee(attendee: Person) {
const teamId = this.teamId;
if (!this.isTeamEvent || !teamId) return;

const attendeePhoneNumber = attendee.phoneNumber;
if (!attendeePhoneNumber) return;
const isPhoneOnlyBooking = attendeePhoneNumber && isSmsCalEmail(attendee.email);

if (!this.isTeamEvent || !teamId || !attendeePhoneNumber || !isPhoneOnlyBooking) return;

const smsMessage = this.getMessage(attendee);
const senderID = getSenderId(attendeePhoneNumber, SENDER_ID);
Expand Down

0 comments on commit 96ff88d

Please sign in to comment.