Files
calendar/packages/features/ee/workflows/lib/reminders/utils.ts
T
e7df1ef493 fix: Create dub links if valid url (#18588)
* Create dub links if valid

* Map through filtered links

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-01-10 15:58:16 +00:00

19 lines
600 B
TypeScript

import { dub } from "@calcom/features/auth/lib/dub";
export const bulkShortenLinks = async (links: string[]) => {
const linksToShorten = links.filter((link) => link !== "");
const results = await dub.links.createMany(
linksToShorten.map((link) => ({ domain: "sms.cal.com", url: link }))
);
return links.map((link) => {
const createdLink = results.find((result) => result.url === link);
if (createdLink) {
return { shortLink: createdLink.shortLink };
// if invalid link, return the original link as it is
} else {
return { shortLink: link };
}
});
};