Skip to content
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

api/reddit: add support for resolving short links in comments #950

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Aholicknight
Copy link

@Aholicknight Aholicknight commented Nov 26, 2024

This pull request introduces a new function to resolve short links (fixes #910) and integrates it into the existing Reddit comment fetching logic. The most significant changes include adding a new helper function and modifying the main export function to handle short links.

Enhancements to URL resolution:

Improvements to main function:

  • api/src/processing/services/reddit.js: Modified the default export function to check for a short link and use the new resolveShortLink function. If a short link is provided and cannot be resolved, it returns an error. Otherwise, it constructs the URL based on the subreddit or user comment path.

let url;

if (obj.shortLink) {
const resolvedUrl = await resolveShortLink(obj.shortLink);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const resolvedUrl = await resolveShortLink(obj.shortLink);
const resolvedUrl = await getRedirectingURL(obj.shortLink);

Comment on lines 51 to 53
async function resolveShortLink(url) {
return await getRedirectingURL(url);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async function resolveShortLink(url) {
return await getRedirectingURL(url);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Short reddit video link isn't recognized
3 participants