-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#18587) This reverts commit 4902c6a. Co-authored-by: Alex van Andel <[email protected]>
- Loading branch information
1 parent
68f76e2
commit 35059d7
Showing
3 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
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 }; | ||
} | ||
}); | ||
export const getShortenLink = (link: string) => { | ||
// don't hit dub with with empty string | ||
if (!link.length) { | ||
const pr: Promise<string> = new Promise((resolve) => resolve(link)); | ||
return pr; | ||
} else { | ||
return dub.links.create({ | ||
url: link, | ||
domain: "sms.cal.com", | ||
}); | ||
} | ||
}; |