Skip to content

Conversation

@Mokkapps
Copy link
Contributor

@Mokkapps Mokkapps commented Jun 24, 2025

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;

  • I have read the CONTRIBUTING guide.
  • I checked that there were not similar issues or PRs already open for this.
  • This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.

Summary by CodeRabbit

  • New Features
    • Added integration with the LinkDrip URL shortening service, allowing users to generate short links using LinkDrip if configured.
  • Chores
    • Updated environment variable examples to include placeholders for LinkDrip service configuration.
@vercel
Copy link

vercel bot commented Jun 24, 2025

@Mokkapps is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jun 24, 2025

Walkthrough

Support for the LinkDrip short link service was added. This includes new environment variable placeholders in .env.example, a new LinkDrip provider class implementing the ShortLinking interface, and updates to the provider selection logic to instantiate LinkDrip when its API key is present.

Changes

File(s) Change Summary
.env.example Added commented-out environment variable placeholders for LinkDrip integration.
libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts Introduced LinkDrip provider class implementing ShortLinking for LinkDrip API integration.
libraries/nestjs-libraries/src/short-linking/short.link.service.ts Updated provider selection logic to support LinkDrip based on environment variables.

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
Loading

Possibly related PRs

Poem

A new link hops into our code,
LinkDrip’s secrets now bestowed.
With API keys tucked in tight,
Short links leap from left to right.
Providers gather, old and new,
As bunnies cheer this feature through!
🐇✨

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts

Oops! Something went wrong! :(

ESLint: 8.57.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/eslintrc' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

libraries/nestjs-libraries/src/short-linking/short.link.service.ts

Oops! Something went wrong! :(

ESLint: 8.57.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/eslintrc' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a09aaa and 980d1fc.

📒 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)
🚧 Files skipped from review as they are similar to previous changes (3)
  • libraries/nestjs-libraries/src/short-linking/short.link.service.ts
  • .env.example
  • libraries/nestjs-libraries/src/short-linking/providers/linkdrip.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-publish
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
Copy link

@coderabbitai coderabbitai bot left a 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 convertShortLinkToLink method 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

📥 Commits

Reviewing files that changed from the base of the PR and between 313380e and 4a09aaa.

📒 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 -e

Locate 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 -->
Comment on lines 22 to 44
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}`);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
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.
@Mokkapps Mokkapps force-pushed the feature/linkdrip-short-linking-provider branch from 4a09aaa to 980d1fc Compare June 27, 2025 06:08
@nevo-david
Copy link
Contributor

Thank you!
However, could you please implement the statistics and shortlink-to-link function?

@Mokkapps
Copy link
Contributor Author

@nevo-david unfortunately, I could not find similar functionalities in LinkDrip API documentation

@nevo-david nevo-david merged commit 8f88bf7 into gitroomhq:main Jul 3, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants