Repository navigation
feat(campaigns): viral sharing — dynamic OG card, QR poster, and thank-you card - #321
Conversation
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
⏱️ Code Review completed (22 eligible files · 136,737 chars · 2 model call(s) · 5 PR unit(s))
Whole diff with bounded context at base cb46d9b / head af54c0d.
Excluded by noise policy: apps/web/src/assets/fonts/BeVietnamPro-Bold.ttf, apps/web/src/assets/fonts/BeVietnamPro-Regular.ttf.
✅ CLEAN_PASS: Complete diff reviewed
Context investigation was bounded to the explicitly requested snapshot paths.
|
PO acceptance: merge at af54c0d Independent PO flagship review (0a76e28d-e4cb-4059-8a59-7185d22ba17e): APPROVE (0 P0/P1/P2 findings).
|
Refs #313
Summary
/campaigns/[slug]/opengraph-image):next/ogImageResponsewith bundled local Be Vietnam Pro TTF fonts (Regular + Bold, OFL 1.1) — zero external runtime fetches / zero SSRF.Từ thiện/Dự án), VND raised/goal progress bar (excludingother_in_amountongive), honest verified statement badge (unexplained_out_count === 0), and Give branding.404withCache-Control: no-storefor draft, in_review, changes_requested, approved, suspended, cancelled, invalid, or nonexistent campaigns (anonymousdbAs()only).generateMetadataon/campaigns/[slug]/page.tsxso static coveropenGraph.imagesdoes not override the dynamicopengraph-imageroute./campaigns/[slug]):"Tải poster QR"secondary action and portaled accessibleModalDialog(Escape, scrim, Tab/Shift+Tab focus trap, focus return) exporting Story (9:16, 1080x1920) and Square (1:1, 1080x1080) PNGs via client-side canvas usinguqr.payments_stopped_atis set (on campaign orpublic_campaignstotals), when stopped-payment status cannot be verified, or when the campaign is not a livegivecampaign inside dates with a usable bank account. Never sends rawaccount_numberoraccount_nameto the client; reusesmaskedAccountLast4for the bank hint."Tôi đã chung tay"Thank-You Card:/donations/[code](only whenstatus === "received"on public campaigns, including live polling transition) and/me/contributions(only for received donations and paid pledges with positive net received amount on public campaigns)."Ẩn số tiền trên thẻ"toggle (default visible, strips all VND digits when enabled), respecting anonymous donations (Người ủng hộ ẩn danh), showing verification reference code (RefCode) and Give transparency footer with zero PII/bank leakage (guest tracking views remain strictly PII-free).Verification
pnpm format:check— passpnpm lint— passpnpm typecheck— passpnpm test— 186 test files, 2,721 tests pass (including OG PNG magic-bytes + 404 tests, Matching hint net of refunds, and older payment notices while payment requests are stopped #93 poster suppression & anti-leak tests, thank-you card privacy/anonymity/RLS/bigint tests, and client bundle boundary checks)pnpm build— pass (Turbopack traced bundled Be Vietnam Pro TTF assets into/campaigns/[slug]/opengraph-image)📌 TL;DR
This PR introduces a "Viral Sharing" feature (#313) that allows users to download shareable QR posters and "Thank You" cards for their donations and pledges. It also implements dynamic Open Graph image generation for campaign pages to improve social media previews, while strictly enforcing PII protection and campaign status visibility rules.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/src/app/campaigns/[slug]/opengraph-image.tsxnext/og. Renders campaign title, progress, and organizer info with bundled Vietnamese fonts. Returns 404 for non-public campaigns.apps/web/src/app/campaigns/[slug]/opengraph-image.test.tsapps/web/src/app/campaigns/[slug]/page.tsxgenerateMetadatato remove static image tags (relying on the new dynamic route). AddsQrPosterButtonto the public campaign view, passing server-side poster data.apps/web/src/app/campaigns/[slug]/page.test.tsapps/web/src/components/QrPosterButton.tsxapps/web/src/components/QrPosterButton.test.tsapps/web/src/components/ThankYouCardButton.tsxapps/web/src/components/DonationStatus.tsxThankYouCardButtonwhen a donation is received and the campaign is public.apps/web/src/app/(public)/donations/[code]/page.tsxloadDonationto resolve the donor's display name. PassesthankYoudata toDonationStatusif the campaign is public and the donation is received.apps/web/src/app/(public)/donations/[code]/page.test.tsapps/web/src/app/me/contributions/page.tsxThankYouCardButtonto received donations and paid pledges on public campaigns.apps/web/src/app/me/contributions/page.test.tsapps/web/src/assets/fonts/OFL.txtapps/web/src/assets/fonts/BeVietnamPro-*.ttf📊 Architectural Flow
sequenceDiagram participant User participant CampaignPage as /campaigns/[slug] participant OGRoute as /campaigns/[slug]/opengraph-image participant PosterBtn as QrPosterButton participant Canvas as Canvas API Note over User, CampaignPage: Social Media Preview User->>OGRoute: Request OG Image OGRoute->>OGRoute: Fetch Campaign (Anon) alt Public Campaign OGRoute->>OGRoute: Render PNG (next/og) OGRoute-->>User: 200 OK (PNG) else Non-Public/Invalid OGRoute-->>User: 404 Not Found end Note over User, PosterBtn: Download Poster User->>CampaignPage: View Public Campaign CampaignPage->>PosterBtn: Render with PosterData User->>PosterBtn: Click "Tải poster QR" PosterBtn->>Canvas: Render QR + Campaign Info Canvas-->>PosterBtn: Preview Image User->>PosterBtn: Click Download PosterBtn->>Canvas: Export to PNG Blob PosterBtn-->>User: Trigger Download