makearmy-app/app/api
makearmy 912cf71bb9 feat(support): Ko-fi end-to-end linking + badges (derive-on-read, no cron)
- Add Ko-fi webhook (/api/webhooks/kofi) with upsert by (provider, external_user_id)
  • Computes renews_at = timestamp + 1 calendar month + 1 day
  • Preserves first started_at; stores raw payload; canonicalizes by email when available
- Add Ko-fi claim flow
  • POST /api/support/kofi/claim/start — sends verification email via SMTP
  • GET  /api/support/kofi/claim/verify — finalizes link (sets app_user), redirects to /portal/account
  • POST /api/support/kofi/unlink — clears app_user on Ko-fi rows
- Add derive-on-read membership logic
  • /lib/memberships.ts — single source of truth for badges & “active” state
  • /api/support/badges — thin wrapper that returns per-provider badges
- Account UI
  • components/account/SupporterBadges.tsx — renders provider badges (Ko-fi now; extensible)
  • components/account/ConnectKofi.tsx — “Link Ko-fi” form (email → verify link)
  • components/account/LinkStatus.tsx — success/error banner on return
  • app/portal/account/AccountPanel.tsx — integrates badges, link panel, and banner
- Config/env
  • Requires: DIRECTUS_URL, DIRECTUS_TOKEN_ADMIN_SUPPORTER, KOFI_VERIFY_TOKEN
  • SMTP: SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USER, SMTP_PASS, EMAIL_FROM
  • APP_ORIGIN used to build absolute verify URLs
- Misc
  • Fixed import to use @/lib/memberships
  • No cron required; UI derives active state via status === active && renews_at >= now

Refs: beta readiness for Ko-fi supporters
2025-10-19 17:51:04 -04:00
..
_lib user auth bearer updates to multiple apis and scripts 2025-09-29 12:39:59 -04:00
account more password change fixes 2025-09-30 22:51:12 -04:00
auth provider fix for registration on main 2025-10-03 12:13:06 -04:00
bgbye/process bgbye routing fix 2025-10-15 19:05:56 -04:00
claims claims route to async 2025-09-27 22:51:37 -04:00
debug debug route 2025-10-02 20:01:35 -04:00
dx/[...path] my-settings tab update 2025-10-02 22:15:06 -04:00
files file server fix + middleware updates 2025-10-15 21:10:28 -04:00
me api/me routing 2025-09-29 12:44:31 -04:00
my-settings/delete fix to populate results in my-settings 2025-10-02 22:25:26 -04:00
project settings overhaul and reset 2025-10-05 17:45:09 -04:00
rigs added exp and apt to rigs. 2025-09-29 23:17:20 -04:00
settings settings overhaul and reset 2025-10-05 17:45:09 -04:00
support feat(support): Ko-fi end-to-end linking + badges (derive-on-read, no cron) 2025-10-19 17:51:04 -04:00
webhooks/kofi feat(support): Ko-fi end-to-end linking + badges (derive-on-read, no cron) 2025-10-19 17:51:04 -04:00