-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add link previews with OG embeds and background worker #14
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0d27a18
feat(chat): add link previews with OG embeds and background worker
BuckyMcYolo 9d11e4f
fix: harden link unfurl pipeline and embed rendering
BuckyMcYolo 4d61943
fix: fixed SSRF vulnerability
BuckyMcYolo d179c82
fix: resolve all ips to filter for private addresses
BuckyMcYolo 9f4a363
fix: fixed multi url parsing and disallowed redirects on OG image
BuckyMcYolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { cn } from "@repo/ui/lib/utils" | ||
| import { ExternalLink } from "lucide-react" | ||
| import type { Message } from "@/lib/api-types" | ||
|
|
||
| type Embed = Message["embeds"][number] | ||
|
|
||
| interface EmbedCardProps { | ||
| embed: Embed | ||
| className?: string | ||
| } | ||
|
|
||
| export function EmbedCard({ embed, className }: EmbedCardProps) { | ||
| const hasMeta = Boolean(embed.title || embed.description) | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "mt-1 max-w-lg overflow-hidden rounded border border-border/70 bg-[hsl(var(--card))]/60", | ||
| "border-l-4 border-l-primary/60", | ||
| className | ||
| )} | ||
| > | ||
| <div className="flex min-w-0 flex-col gap-1.5 p-3"> | ||
| {embed.title && ( | ||
| <a | ||
| href={embed.url} | ||
| target="_blank" | ||
| rel="noreferrer noopener" | ||
| className="line-clamp-2 text-sm font-semibold text-primary hover:underline" | ||
| > | ||
| {embed.title} | ||
| </a> | ||
| )} | ||
| {embed.description && ( | ||
| <p className="whitespace-pre-line text-[13px] leading-snug text-muted-foreground"> | ||
| {embed.description} | ||
| </p> | ||
| )} | ||
| {!hasMeta && ( | ||
| <a | ||
| href={embed.url} | ||
| target="_blank" | ||
| rel="noreferrer noopener" | ||
| className="inline-flex items-center gap-1 text-sm text-primary hover:underline" | ||
| > | ||
| <ExternalLink className="size-3.5" /> | ||
| {embed.url} | ||
| </a> | ||
| )} | ||
| </div> | ||
| {embed.thumbnail && | ||
| (embed.title || embed.description || embed.siteName) && ( | ||
| <div className="px-3 pb-3"> | ||
| <img | ||
| src={embed.thumbnail} | ||
| alt={embed.title ?? "Link preview"} | ||
| className="w-full rounded object-cover" | ||
| loading="lazy" | ||
| onError={(e) => { | ||
| e.currentTarget.style.display = "none" | ||
| }} | ||
| /> | ||
| </div> | ||
| )} | ||
| {embed.siteName && ( | ||
| <div className="flex items-center gap-1.5 border-t border-border/50 px-3 py-2"> | ||
| <span className="text-xs text-muted-foreground"> | ||
| {embed.siteName} | ||
| </span> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "name": "@repo/worker", | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "tsx watch src/index.ts", | ||
| "build": "tsup", | ||
| "start": "node dist/index.js", | ||
| "check-types": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@repo/db": "workspace:*", | ||
| "@repo/env": "workspace:*", | ||
| "@repo/realtime-types": "workspace:*", | ||
| "@socket.io/redis-emitter": "^5.1.0", | ||
| "bullmq": "^5.70.2", | ||
| "open-graph-scraper": "^6.11.0", | ||
| "redis": "^4.7.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@repo/typescript-config": "workspace:*", | ||
| "tsup": "^8.5.1", | ||
| "tsx": "^4.21.0" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.