Skip to content

feat(campaigns): viral sharing — dynamic OG card, QR poster, and thank-you card - #321

Merged
JOY (JOY) merged 1 commit into
devfrom
antigravity/give-313-viral-sharing
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
antigravity/give-313-viral-sharing

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs #313

Summary

  • Dynamic Open Graph image (/campaigns/[slug]/opengraph-image):
    • Renders 1200x630 PNG via next/og ImageResponse with bundled local Be Vietnam Pro TTF fonts (Regular + Bold, OFL 1.1) — zero external runtime fetches / zero SSRF.
    • Shows campaign title, type badge (Từ thiện / Dự án), VND raised/goal progress bar (excluding other_in_amount on give), honest verified statement badge (unexplained_out_count === 0), and Give branding.
    • Strictly returns 404 with Cache-Control: no-store for draft, in_review, changes_requested, approved, suspended, cancelled, invalid, or nonexistent campaigns (anonymous dbAs() only).
    • Updated generateMetadata on /campaigns/[slug]/page.tsx so static cover openGraph.images does not override the dynamic opengraph-image route.
  • Downloadable QR Poster (/campaigns/[slug]):
    • Added "Tải poster QR" secondary action and portaled accessible ModalDialog (Escape, scrim, Tab/Shift+Tab focus trap, focus return) exporting Story (9:16, 1080x1920) and Square (1:1, 1080x1080) PNGs via client-side canvas using uqr.
    • Matching hint net of refunds, and older payment notices while payment requests are stopped #93 & anti-leak safety: Strictly suppresses VietQR / payment instructions whenever payments_stopped_at is set (on campaign or public_campaigns totals), when stopped-payment status cannot be verified, or when the campaign is not a live give campaign inside dates with a usable bank account. Never sends raw account_number or account_name to the client; reuses maskedAccountLast4 for the bank hint.
  • Shareable "Tôi đã chung tay" Thank-You Card:
    • Added to /donations/[code] (only when status === "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).
    • Client-side 1080x1080 PNG export with a user-controlled "Ẩ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 — pass
  • pnpm lint — pass
  • pnpm typecheck — pass
  • pnpm 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)
  • Fresh-context security & DESIGN.md review completed and all Medium/Minor findings resolved before PR creation.

📌 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

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/app/campaigns/[slug]/opengraph-image.tsx New: Implements dynamic OG image generation (1200x630 PNG) using next/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.ts New: Tests for the OG image route, verifying PNG output, cache headers, font loading, and 404 behavior for invalid/non-public slugs.
apps/web/src/app/campaigns/[slug]/page.tsx Updates generateMetadata to remove static image tags (relying on the new dynamic route). Adds QrPosterButton to the public campaign view, passing server-side poster data.
apps/web/src/app/campaigns/[slug]/page.test.ts Updates metadata tests to reflect the removal of static images. Adds tests for the "Tải poster QR" button visibility and PII masking (ensuring account numbers/names are not leaked).
apps/web/src/components/QrPosterButton.tsx New: Client component that renders a modal with a canvas-based preview of the QR poster. Supports Story (9:16) and Square (1:1) formats. Handles PNG export and download.
apps/web/src/components/QrPosterButton.test.ts New: Tests for the poster modal, verifying canvas rendering, format switching, focus trapping, and download functionality.
apps/web/src/components/ThankYouCardButton.tsx New (implied by imports): Component to render the "Thank You" card download button.
apps/web/src/components/DonationStatus.tsx Updates the donation status view to display the ThankYouCardButton when a donation is received and the campaign is public.
apps/web/src/app/(public)/donations/[code]/page.tsx Updates loadDonation to resolve the donor's display name. Passes thankYou data to DonationStatus if the campaign is public and the donation is received.
apps/web/src/app/(public)/donations/[code]/page.test.ts Adds tests to verify the "Thank You" card button appears only when the donation is received and the campaign is public.
apps/web/src/app/me/contributions/page.tsx Updates the user's contribution list to include campaign status. Adds ThankYouCardButton to received donations and paid pledges on public campaigns.
apps/web/src/app/me/contributions/page.test.ts Adds tests to verify the "Thank You" card button logic, including edge cases like suspended campaigns and string-based bigint amounts.
apps/web/src/assets/fonts/OFL.txt New: Adds the SIL Open Font License for the Be Vietnam Pro font.
apps/web/src/assets/fonts/BeVietnamPro-*.ttf New: Adds the font files used for OG image and poster generation.

📊 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
Loading

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

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.

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 1:29pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 731e7534-2ae4-48db-af21-d8dc24ae8b20

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱️ 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.

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at af54c0d

Independent PO flagship review (0a76e28d-e4cb-4059-8a59-7185d22ba17e): APPROVE (0 P0/P1/P2 findings).

@JOY
JOY (JOY) merged commit 4c1b736 into dev Nov 22, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-313-viral-sharing branch November 22, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant