fix(newsletter): email rendering bugs and unsubscribe confirmation #78

Merged
addison merged 4 commits from exe-dev-bot/market:fix/newsletter-email-bugs into main 2026-02-12 05:15:28 -05:00
Contributor

Summary

Fixes several bugs in the weekly newsletter email and the unsubscribe page.

Changes

Email rendering fixes (src/lib/newsletter-email.ts)

  • Items and vendors are now clickable links — items link to /items/{id}, vendors link to /v/{vendor_id}. Footer links (Privacy Policy, Content Policy) also made absolute using siteUrl.
  • Vendor avatar fallback matches browser view — replaced inline HTML initials <div> with DiceBear SVG (https://api.dicebear.com/7.x/initials/svg?seed=...), consistent with the in-browser newsletter.
  • Price hidden for requests — buy items with no price no longer show "Price not listed". Sell items retain the fallback.
  • Removed copyright line from email footer.

Delivery pipeline (src/lib/newsletter-delivery.ts)

  • Passes siteUrl to renderNewsletterEmail() for absolute link generation.

Unsubscribe confirmation (src/pages/newsletter/unsubscribe.astro)

  • Added confirmation step — GET validates the token and shows a confirmation form; POST performs the actual unsubscribe. Previously, clicking the link instantly unsubscribed with no confirmation.
  • Uses server-rendered form (no client JS) for CAN-SPAM compliance.
  • Fixed settings link: /my/settings/profile/edit (the actual page where newsletter opt-in lives).

Testing

  • Trigger a newsletter locally (POST /api/newsletter/trigger) and verify:
    • Items and vendors are clickable links in the received email
    • Vendor avatars without custom images show DiceBear initials
    • Requests without prices do not show "Price not listed"
    • No copyright line in footer
  • Click the unsubscribe link in a newsletter email and verify:
    • Confirmation page appears (not instant unsubscribe)
    • Clicking "Yes, unsubscribe" completes the action
    • Success page links to /profile/edit (not /my/settings)
    • Invalid/missing tokens show appropriate error messages
## Summary Fixes several bugs in the weekly newsletter email and the unsubscribe page. ## Changes ### Email rendering fixes (`src/lib/newsletter-email.ts`) - **Items and vendors are now clickable links** — items link to `/items/{id}`, vendors link to `/v/{vendor_id}`. Footer links (Privacy Policy, Content Policy) also made absolute using `siteUrl`. - **Vendor avatar fallback matches browser view** — replaced inline HTML initials `<div>` with DiceBear SVG (`https://api.dicebear.com/7.x/initials/svg?seed=...`), consistent with the in-browser newsletter. - **Price hidden for requests** — buy items with no price no longer show "Price not listed". Sell items retain the fallback. - **Removed copyright line** from email footer. ### Delivery pipeline (`src/lib/newsletter-delivery.ts`) - Passes `siteUrl` to `renderNewsletterEmail()` for absolute link generation. ### Unsubscribe confirmation (`src/pages/newsletter/unsubscribe.astro`) - **Added confirmation step** — GET validates the token and shows a confirmation form; POST performs the actual unsubscribe. Previously, clicking the link instantly unsubscribed with no confirmation. - Uses server-rendered form (no client JS) for CAN-SPAM compliance. - Fixed settings link: `/my/settings` → `/profile/edit` (the actual page where newsletter opt-in lives). ## Testing - [ ] Trigger a newsletter locally (`POST /api/newsletter/trigger`) and verify: - Items and vendors are clickable links in the received email - Vendor avatars without custom images show DiceBear initials - Requests without prices do not show "Price not listed" - No copyright line in footer - [ ] Click the unsubscribe link in a newsletter email and verify: - Confirmation page appears (not instant unsubscribe) - Clicking "Yes, unsubscribe" completes the action - Success page links to `/profile/edit` (not `/my/settings`) - Invalid/missing tokens show appropriate error messages
- Wrap items in <a href="${siteUrl}/items/${id}"> and vendors in
  <a href="${siteUrl}/v/${vendor_id}"> with color:inherit styling
- Add siteUrl parameter to renderNewsletterEmail and pass it from
  newsletter-delivery.ts processUser; also fix footer policy links
  to use absolute URLs
- Replace inline div initials fallback with DiceBear initials SVG
  img tag to match the in-browser view
- Add itemType parameter to renderItem; for buy items, hide the
  price line entirely when price_string is falsy instead of showing
  "Price not listed"

Co-authored-by: Shelley <shelley@exe.dev>
Co-authored-by: Shelley <shelley@exe.dev>
Co-authored-by: Shelley <shelley@exe.dev>
fix(newsletter): remove copyright line from email footer
Some checks failed
CI / Lint, Type Check, Format & Unit Tests (pull_request) Successful in 1m49s
CI / E2E Tests (pull_request) Failing after 2m37s
08df54864a
Co-authored-by: Shelley <shelley@exe.dev>
addison deleted branch fix/newsletter-email-bugs 2026-02-12 05:15:28 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kwila/market!78
No description provided.