Skip to content

Commit

Permalink
use bulkShortenLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Jan 16, 2025
1 parent 651c574 commit dea24d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
24 changes: 3 additions & 21 deletions packages/features/ee/workflows/api/scheduleSMSReminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { NextApiRequest, NextApiResponse } from "next";

import dayjs from "@calcom/dayjs";
import { getShortenLink } from "@calcom/ee/workflows/lib/reminders/utils";
import { bulkShortenLinks } from "@calcom/ee/workflows/lib/reminders/utils";
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
import { defaultHandler } from "@calcom/lib/server";
Expand Down Expand Up @@ -127,26 +127,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
rescheduleLink: `${bookerUrl}/reschedule/${reminder.booking.uid}` || "",
};

const [meetingUrl, cancelLink, rescheduleLink] = await Promise.allSettled([
getShortenLink(urls.meetingUrl),
getShortenLink(urls.cancelLink),
getShortenLink(urls.rescheduleLink),
]).then((results) => {
return results.map((result) => {
let finalResult = "";

if (result.status === "fulfilled") {
const v = result.value;
if (typeof v === "string") {
finalResult = v;
} else {
finalResult = v.shortLink;
}
}

return finalResult;
});
});
const [{ shortLink: meetingUrl }, { shortLink: cancelLink }, { shortLink: rescheduleLink }] =
await bulkShortenLinks([urls.meetingUrl, urls.cancelLink, urls.rescheduleLink]);

const variables: VariablesType = {
eventName: reminder.booking?.eventType?.title,
Expand Down
24 changes: 3 additions & 21 deletions packages/features/ee/workflows/lib/reminders/smsReminderManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from "@calcom/dayjs";
import { getShortenLink } from "@calcom/ee/workflows/lib/reminders/utils";
import { bulkShortenLinks } from "@calcom/ee/workflows/lib/reminders/utils";
import { SENDER_ID, WEBSITE_URL } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import type { TimeFormat } from "@calcom/lib/timeFormat";
Expand Down Expand Up @@ -153,26 +153,8 @@ export const scheduleSMSReminder = async (args: ScheduleTextReminderArgs) => {
rescheduleLink: `${evt.bookerUrl ?? WEBSITE_URL}/reschedule/${evt.uid}`,
};

const [meetingUrl, cancelLink, rescheduleLink] = await Promise.allSettled([
getShortenLink(urls.meetingUrl),
getShortenLink(urls.cancelLink),
getShortenLink(urls.rescheduleLink),
]).then((results) => {
return results.map((result) => {
let finalResult = "";

if (result.status === "fulfilled") {
const v = result.value;
if (typeof v === "string") {
finalResult = v;
} else {
finalResult = v.shortLink;
}
}

return finalResult;
});
});
const [{ shortLink: meetingUrl }, { shortLink: cancelLink }, { shortLink: rescheduleLink }] =
await bulkShortenLinks([urls.meetingUrl, urls.cancelLink, urls.rescheduleLink]);

const variables: VariablesType = {
eventName: evt.title,
Expand Down

0 comments on commit dea24d2

Please sign in to comment.