Files
calendar/packages/features/ee/workflows/lib/reminders/utils.ts
T
be53a20429 feat: Use Folders to organize SMS links on Dub (#19248)
* feat: Use Folders to organize SMS links on Dub

* Update yarn.lock

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk>
2025-02-15 10:06:28 +00:00

24 lines
693 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,
folderId: "fold_wx3NZDKQYbLDbncSubeMu0ss",
}))
);
return links.map((link) => {
const createdLink = results.find(
(result): result is Extract<typeof result, { url: string }> =>
!("error" in result) && result.url === link
);
if (createdLink) {
return { shortLink: createdLink.shortLink };
} else {
return { shortLink: link };
}
});
};