Skip to content

feat: add email notification system for bounty updates (#841) [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] - #1457

Open
waterWang wants to merge 1 commit into
SolFoundry:mainfrom
waterWang:feat/email-notification-841
Open

feat: add email notification system for bounty updates (#841) [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]#1457
waterWang wants to merge 1 commit into
SolFoundry:mainfrom
waterWang:feat/email-notification-841

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Implements the Email Notification System for bounty updates (Bounty #841, T2 Backend, 400K FNDRY).

Contributors can now receive email alerts when bounties matching their interests are posted, updated, or completed, with digest options and delivery tracking / bounce handling.

What's included

Email templates (backend/app/email_templates.py)

  • 🔨 New Bounty — dark-themed card with tier badge, reward, and skill tags
  • 📋 Status Update — color-coded status change (approved / changes_requested / merged / cancelled)
  • 💰 Payout — reward amount display with transaction link
  • 📊 Weekly/Daily Digest — aggregated new + completed bounties

Email service (backend/app/email_service.py)

  • SendGrid REST API delivery (already uses httpx, an existing backend dependency)
  • Falls back to dev-mode logging when SENDGRID_API_KEY is unset
  • Supports tracking_id custom args for delivery correlation

User preference management (backend/app/services/preference_store.py)

  • Persistent JSON-file-backed store (survives restarts — not an in-memory dict)
  • Per-user: contact email, notification frequency (instant/daily/weekly/off), per-type opt-in/opt-out, digest day
  • Thread-safe, atomic writes

Notification orchestration (backend/app/services/notify.py)

  • notify_bounty_event() — single entry point that the bounty create / update / complete flows call
  • Looks up subscribers who opted into each event type and respects their frequency preference
  • Returns the number of emails sent

Endpoints (backend/app/api/v1/endpoints/)

  • GET /api/notifications/preferences — read a user's preferences
  • PUT /api/notifications/preferences — update preferences
  • POST /api/notifications/send — test/admin trigger
  • POST /api/webhooks/sendgrid/events — SendGrid delivery webhook (bounce handling)

Tests (backend/test_email_notifications.py)

  • 15 tests: template rendering, SendGrid success/failure, preference persistence, notification routing — all passing

Acceptance criteria coverage

  • ✅ Email templates for bounty updates and status changes
  • ✅ User preference management for notification frequency
  • ✅ Email delivery tracking and bounce handling (SendGrid event webhook)

Closes #841

… [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🏭 Bounty T2: Email Notification System for Bounty Updates

1 participant