Skip to content

Feat/1211 1370 1369 1371 - #1647

Merged
davedumto merged 7 commits into
StreamFi-x:devfrom
OsagieCynthia:feat/1211-1370-1369-1371
Oct 3, 2026
Merged

davedumto merged 7 commits into
StreamFi-x:devfrom
OsagieCynthia:feat/1211-1370-1369-1371

Conversation

@OsagieCynthia

Copy link
Copy Markdown
Contributor

Notification System Improvements: Preferences & Templating

Overview

This PR implements two critical improvements to StreamFi's notification system:

  1. feat: In-app notification preferences and unsubscribe management for users #1369: In-app notification preferences and unsubscribe management - Users can now granularly control which notifications they receive across in-app and email channels, with a global unsubscribe option.

  2. feat: Templating and localization layer for notification content #1370: Templating and localization layer for notification content - All notifications now use a centralized template system with i18n support for English and Spanish, eliminating hardcoded strings and enabling consistent, translatable messaging.

What Changed

Database Layer

  • Added notification_preferences table with per-user, per-channel, per-type controls
  • Migration auto-populates defaults for existing users
  • Supports both in-app and email notification toggles for 7+ notification types
  • Global unsubscribe flag for complete opt-out

API Endpoints

  • Migrated /api/routes-f/notification-preferences from in-memory to database storage
  • Now supports authenticated session-based and query param-based lookups
  • Full CRUD operations with persistent updates

Template Engine

  • New lib/notifications/template-engine.ts with renderNotification() and createNotificationRecord()
  • Supports variable interpolation ({{actor}}, {{amount}}, etc.)
  • Handles pluralization across languages
  • 8 notification types with English and Spanish templates

UI Component

  • Updated NotificationSettings component to fetch and persist preferences in real-time
  • Organized toggles by channel (In-app, Email)
  • Displays 7 in-app notification types and 5 email types
  • Optimistic UI updates with error handling
  • Global unsubscribe button

Notification Trigger Points

  • app/api/users/follow/route.ts - checks notify_follow before sending
  • app/api/streams/start/route.ts - checks notify_live before notifying followers
  • app/api/routes-f/webhooks-stellar-payment/route.ts - checks notify_tip_received for tip alerts
  • lib/routes-f/badges.ts - checks notify_system for badge notifications

Implementation Details

New Files

  • db/migrations/20260925_notification_preferences.sql
  • lib/notifications/template-engine.ts
  • lib/notifications/preferences.ts

Modified Files

  • app/api/routes-f/notification-preferences/route.ts - API migration
  • app/api/users/follow/route.ts - Preference checking
  • app/api/streams/start/route.ts - Preference checking
  • app/api/routes-f/webhooks-stellar-payment/route.ts - Preference checking
  • lib/routes-f/badges.ts - Preference checking
  • lib/notifications.ts - Added writeTemplatedNotification()
  • lib/i18n/translator.ts - Added notification templates
  • components/settings/notifications/NotificationSettings.tsx - UI rewrite

Closes

Testing Notes

  • Notification preferences are fetched from database on component mount
  • Toggling preferences immediately persists to database with optimistic UI updates
  • Preference checks skip notification delivery when disabled
  • Template rendering works for all 8 notification types in English and Spanish
  • Pluralization rules correctly handle singular/plural forms

Migration Path

  • Existing users get all defaults applied on first fetch
  • No breaking changes to notification API contract
  • Backward compatible with existing notification code (deprecated old writeNotification)

…er (StreamFi-x#1369)

- Create notification_preferences table with per-user notification controls
- Add NotificationPreferences interface with support for in-app and email channels
- Implement getNotificationPreferences, updateNotificationPreferences functions
- Add preference checking functions: shouldSendInAppNotification, shouldSendEmailNotification
- Implement global unsubscribe/resubscribe functionality
- Include migration that populates defaults for existing users
…mFi-x#1370)

- Create lib/notifications/template-engine.ts with renderNotification()
- Support pluralization rules for notification content across languages
- Add comprehensive English and Spanish templates for all notification types
- Implement variable interpolation with proper escaping
- Add writeTemplatedNotification() function for template-based writes
- Deprecate hardcoded writeNotification() in favor of templated approach
…mFi-x#1369)

- Replace in-memory prefsStore with database-backed storage
- Update GET endpoint to support both session-based and query param lookup
- Update PUT endpoint to persist updates to notification_preferences table
- Add support for granular per-type notification controls
- Add global unsubscribe/resubscribe functionality via unsubscribed_all flag
- Implement fallback to defaults for missing user preferences
…se (StreamFi-x#1369)

- Implement real-time preference fetching from database API
- Add support for granular in-app and email notification toggles
- Implement optimistic UI updates with server sync
- Add error handling and loading states
- Support per-notification-type controls for 7 in-app types and 5 email types
- Add global unsubscribe button for complete opt-out
- Display current user authentication status with helpful messages
- Update follow notification to check notify_follow preference
- Update stream start notifications to check notify_live preference
- Import shouldSendInAppNotification and writeTemplatedNotification
- Skip notification delivery if user has disabled notification type
- Use templated notifications with i18n support for consistent messaging
- Update tip notification webhook to check notify_tip_received preference
- Update badge notification logic to check notify_system preference
- Import shouldSendInAppNotification and writeTemplatedNotification
- Skip notification delivery if user has disabled notification type
- Support templated notifications with proper parameter passing
@drips-wave

drips-wave Bot commented Sep 25, 2026

Copy link
Copy Markdown

@OsagieCynthia Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

Deployment failed for project streamfi-frontend with the following error:

Invalid vercel.json file provided

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
streamfi-frontend Error Error Sep 25, 2026 11:05pm UTC

@vercel

vercel Bot commented Oct 3, 2026

Copy link
Copy Markdown

@OsagieCynthia is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto
davedumto merged commit 0783fbd into StreamFi-x:dev Oct 3, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants