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>
This commit is contained in:
Joe Au-YeungandAnik Dhabal Babu authored and GitHub committed 2025-01-10 15:58:16 +00:00
1 parent b652ae7714
commit e7df1ef493
1 file changed
+4 -1
@@ -1,7 +1,10 @@
import { dub } from "@calcom/features/auth/lib/dub";
export const bulkShortenLinks = async (links: string[]) => {
const results = await dub.links.createMany(links.map((link) => ({ domain: "sms.cal.com", url: link })));
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);