feat: Add rich link previews on posts to Bluesky, LinkedIn, and Facebook
Uses OpenGraph scraping for LinkedIn, API link parameter for Facebook, and app.bsky.embed.external for Bluesky. Adds PostizBot user agents to metadata fetching to make it distinguishable to firewalls.
What kind of change does this PR introduce?
Before, Postiz posts to Bluesky, LinkedIn, and Facebook would appear without dedicated link previews. They'd appear as plain URLs, without the headline/description/thumbnail you'd get if you posted to the platforms directly. This PR adds custom code for those three platforms to deliver those URLs as distinct objects in the ways their various APIs prefer. Now there are link previews!
Why was this change needed?
I was frustrated seeing these subpar posts appear on social networks important to my website, and it was preventing me from pushing to adopt Postiz for our organization — knowing that the output wasn't as good in this particular way as Buffer or other competitors. (This PR also fixes #667.)
Other information:
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
- [X] I have read the CONTRIBUTING guide.
- [X] I checked that there were not similar issues or PRs already open for this.
- [X] 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 support for rich link previews in Bluesky, Facebook, and LinkedIn posts when sharing URLs without media attachments. Posts now display enhanced previews with title, description, and thumbnail where available.
- Improved Facebook link preview reliability by prewarming Facebook's scraper for shared links.
- Enhanced LinkedIn Page and personal post workflows to include OpenGraph-based link previews and thumbnails.
-
Bug Fixes
- Improved error handling to ensure posts are still created even if link metadata or thumbnails cannot be fetched.
@jbenton is attempting to deploy a commit to the Listinai Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
The changes introduce OpenGraph URL preview support for Bluesky, Facebook, and LinkedIn providers. New utility functions extract URLs from post text and fetch OpenGraph metadata. Posting logic is updated to detect URLs and, if no media is attached, generate and attach rich link previews using fetched metadata. Error handling is incorporated throughout.
Changes
| File(s) | Change Summary |
|---|---|
| .../social/bluesky.provider.ts | Added OpenGraph metadata fetcher, URL extraction, and external embed creation for URL previews in posts without media. Modified post method to use these utilities. |
| .../social/facebook.provider.ts | Added OpenGraph fetcher and URL extraction utilities. Enhanced post method to support link previews via Facebook's link parameter and prewarming scraper. Added prewarmFacebookScraper method. |
| .../social/linkedin.provider.ts, .../social/linkedin.page.provider.ts | Added OpenGraph fetcher, URL extraction, and content entity creation for link previews. Updated post and payload creation methods to support link previews when no media is present. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant Provider
participant OpenGraphFetcher
participant MediaUploader
participant SocialAPI
User->>Provider: Submit post with text (may include URL)
Provider->>Provider: Extract URLs from text
alt No media attached and URL found
Provider->>OpenGraphFetcher: fetchOpenGraphData(url)
OpenGraphFetcher-->>Provider: Return metadata (title, desc, image)
alt Image present in metadata
Provider->>MediaUploader: Upload image as thumbnail
MediaUploader-->>Provider: Return image reference
end
Provider->>SocialAPI: Post content with external embed/link preview
else Media attached or no URL
Provider->>SocialAPI: Post content with media or plain text
end
SocialAPI-->>Provider: Return post response
Provider-->>User: Return post result
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Add URL preview feature to posts in Bluesky, loading OpenGraph info and removing URL from text (#667) | ✅ |
Assessment against linked issues: Out-of-scope changes
| Code Change | Explanation |
|---|
Suggested reviewers
- nevo-david
- egelhaus
Poem
A rabbit hops with glee,
"Now links have previews—oh, what a spree!
Titles and images, all in a row,
Posts on Bluesky, LinkedIn, Facebook now glow.
With OpenGraph magic, the world can see,
Just what’s behind every URL—yippee!"
🐇✨
[!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/integrations/social/bluesky.provider.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:201:49)
libraries/nestjs-libraries/src/integrations/social/facebook.provider.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:201:49)
libraries/nestjs-libraries/src/integrations/social/linkedin.provider.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:201:49)
- 1 others
✨ 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.
🪧 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
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Thanks!
Definitely worth reviewing and merging into the main. @nevo-david
This PR is stale because it has been open for 90 days with no activity.
@nevo-david @egelhaus any interest in this PR?