-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: add LinkDrip provider for short linking service #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add LinkDrip provider for short linking service #836
Conversation
|
@Mokkapps is attempting to deploy a commit to the Listinai Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughSupport for the LinkDrip short link service was added. This includes new environment variable placeholders in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ShortLinkService
participant LinkDripProvider
participant LinkDripAPI
Client->>ShortLinkService: Request to shorten URL
ShortLinkService->>LinkDripProvider: convertLinkToShortLink(url)
LinkDripProvider->>LinkDripAPI: POST /api/links (with API key, domain, url)
LinkDripAPI-->>LinkDripProvider: Shortened link response
LinkDripProvider-->>ShortLinkService: Return short link
ShortLinkService-->>Client: Return short link
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
libraries/nestjs-libraries/src/short-linking/providers/linkdrip.tsOops! Something went wrong! :( ESLint: 8.57.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/eslintrc' imported from /eslint.config.mjs libraries/nestjs-libraries/src/short-linking/short.link.service.tsOops! Something went wrong! :( ESLint: 8.57.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/eslintrc' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts (2)
44-46: Consider implementing reverse link conversion if supported by LinkDrip API.The
convertShortLinkToLinkmethod returns an empty string. If LinkDrip API supports retrieving original URLs from short links, consider implementing this functionality for completeness.
18-20: Consider implementing statistics methods if supported by LinkDrip API.The statistics methods return empty arrays. If LinkDrip API provides link analytics, implementing these methods would enhance the functionality and provide users with valuable insights.
Also applies to: 48-53
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.env.example(1 hunks)libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts(1 hunks)libraries/nestjs-libraries/src/short-linking/short.link.service.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-and-publish
🔇 Additional comments (4)
.env.example (1)
114-116: LGTM! Environment variables follow established patterns.The LinkDrip environment variables are properly structured and consistent with existing short-linking service configurations.
libraries/nestjs-libraries/src/short-linking/short.link.service.ts (2)
7-7: LGTM! Import statement correctly added.The LinkDrip import follows the established pattern and is properly placed with other provider imports.
22-24: LGTM! Provider selection logic correctly implemented.The LinkDrip provider selection follows the same pattern as existing providers and is appropriately positioned before the Empty fallback.
libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts (1)
24-24: ```shell
#!/bin/bash
set -eLocate the definition of LINK_DRIP_API_ENDPOINT
rg -n "LINK_DRIP_API_ENDPOINT" -n libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts
Show the first 200 lines of the provider to inspect headers and body
sed -n '1,200p' libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts
</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| async convertLinkToShortLink(link: string) { | ||
| try { | ||
| const response = await fetch(`${LINK_DRIP_API_ENDPOINT}/create`, { | ||
| ...getOptions(), | ||
| method: 'POST', | ||
| body: JSON.stringify({ | ||
| target_url: link, | ||
| custom_domain: this.shortLinkDomain, | ||
| }), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error(`HTTP error! status: ${response.status}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| return data.link; | ||
| } catch (error) { | ||
| throw new Error(`Failed to create short link: ${error}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix method signature to match interface requirements.
The convertLinkToShortLink method signature doesn't match the ShortLinking interface. It should accept both id and link parameters.
Additionally, there's a potential URL construction issue where the API endpoint already ends with /v1/ but you're appending /create, which could result in double slashes.
Apply this diff to fix both issues:
- async convertLinkToShortLink(link: string) {
+ async convertLinkToShortLink(id: string, link: string) {
try {
- const response = await fetch(`${LINK_DRIP_API_ENDPOINT}/create`, {
+ const response = await fetch(`${LINK_DRIP_API_ENDPOINT}create`, {
...getOptions(),
method: 'POST',
body: JSON.stringify({
target_url: link,
custom_domain: this.shortLinkDomain,
}),
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async convertLinkToShortLink(link: string) { | |
| try { | |
| const response = await fetch(`${LINK_DRIP_API_ENDPOINT}/create`, { | |
| ...getOptions(), | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| target_url: link, | |
| custom_domain: this.shortLinkDomain, | |
| }), | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`HTTP error! status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| return data.link; | |
| } catch (error) { | |
| throw new Error(`Failed to create short link: ${error}`); | |
| } | |
| } | |
| async convertLinkToShortLink(id: string, link: string) { | |
| try { | |
| const response = await fetch(`${LINK_DRIP_API_ENDPOINT}create`, { | |
| ...getOptions(), | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| target_url: link, | |
| custom_domain: this.shortLinkDomain, | |
| }), | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`HTTP error! status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| return data.link; | |
| } catch (error) { | |
| throw new Error(`Failed to create short link: ${error}`); | |
| } | |
| } |
🤖 Prompt for AI Agents
In libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts between
lines 22 and 42, update the convertLinkToShortLink method signature to accept
both id and link parameters as required by the ShortLinking interface. Also,
adjust the URL construction to avoid double slashes by ensuring the endpoint and
path are concatenated correctly, removing the extra slash if the endpoint
already ends with one.
4a09aaa to
980d1fc
Compare
|
Thank you! |
|
@nevo-david unfortunately, I could not find similar functionalities in LinkDrip API documentation |
What kind of change does this PR introduce?
Feature
Why was this change needed?
I have a lifetime deal for LinkDrip and want to use it in Postiz.
Other information:
eg: Did you discuss this change with anybody before working on it (not required, but can be a good idea for bigger changes). Any plans for the future, etc?
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
Summary by CodeRabbit