Skip to content

Enable Email Notifications for Tasks and Projects #976

Description

@chrisvel

Description

Tududi has a partially implemented email notification system that needs to be completed and enabled. The infrastructure (email service, notification model, user preferences) exists but is disabled in the UI and lacks the scheduled notification jobs to trigger emails.

Current State

Already Implemented:

  • Email service with nodemailer (backend/services/emailService.js)
  • Notification model with email channel support (backend/models/notification.js)
  • User notification preferences UI with email toggles (disabled)
  • Email sending when notifications are created with sources.includes('email')

Not Yet Working:

  • Email toggles are disabled in the UI (marked as "Coming Soon")
  • No scheduled cron jobs to generate notifications
  • User preferences for email are not respected in notification creation

Expected Behavior

Users should be able to:

  1. Enable/disable email notifications for different notification types in Profile > Notifications
  2. Receive email notifications based on their preferences for:
    • Due Tasks: Tasks due within 24 hours
    • Overdue Tasks: Tasks that have passed their due date
    • Defer Until: Tasks that are now available to work on
    • Due Projects: Projects due within 24 hours
    • Overdue Projects: Projects that have passed their due date

Implementation Requirements

1. Enable Email in UI

  • Remove "Coming Soon" label from email column in NotificationsTab
  • Change email toggle availability from false to true in frontend/components/Profile/tabs/NotificationsTab.tsx
  • Add email configuration check (similar to Telegram check)

2. Create Notification Scheduler Service

Create backend/services/notificationScheduler.js with cron jobs for:

  • Due soon checks (run hourly): Find tasks/projects due in next 24h
  • Overdue checks (run daily at 6 AM): Find overdue tasks/projects
  • Defer until checks (run every 15 min): Find tasks that just became available

3. Respect User Preferences

When creating notifications, check user's notification preferences:

  • Load user's notification_preferences from profile
  • Only add 'email' to sources array if user has enabled email for that notification type
  • Update notification creation logic to check preferences before sending

4. Email Templates

Create HTML email templates for better formatting:

  • Task due soon template
  • Task overdue template
  • Project due soon template
  • Project overdue template
  • Defer until available template

5. Email Configuration Validation

Add UI to check email configuration status:

  • Show warning if email is enabled but SMTP not configured
  • Add test email button (similar to test notification)

6. Testing

  • Unit tests for notification scheduler
  • Integration tests for email sending with preferences
  • E2E tests for enabling/disabling email notifications

Technical Files to Modify

Frontend:

  • frontend/components/Profile/tabs/NotificationsTab.tsx - Enable email toggles
  • frontend/components/Profile/tabs/types.ts - Type definitions (if needed)

Backend:

  • backend/services/notificationScheduler.js - NEW: Create scheduler service
  • backend/services/emailTemplates.js - NEW: Email HTML templates
  • backend/models/notification.js - Update to check user preferences
  • backend/server.js - Initialize notification scheduler on startup

Testing:

  • backend/tests/services/notificationScheduler.test.js - NEW
  • backend/tests/services/emailService.test.js - Expand existing tests

Environment Variables Required

Users will need to configure (already documented):

EMAIL_ENABLED=true
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@example.com
SMTP_PASS=your-password
EMAIL_FROM_ADDRESS=noreply@tududi.com
EMAIL_FROM_NAME=Tududi Notifications

Acceptance Criteria

  • Email toggles are enabled in Profile > Notifications tab
  • Users can enable/disable email for each notification type
  • Cron jobs run on schedule and create notifications
  • Notifications respect user preferences (only send email if enabled)
  • Emails are properly formatted with HTML templates
  • Test notification button sends email when email is enabled
  • Warning shown if email enabled but SMTP not configured
  • All tests pass
  • Documentation updated

Additional Context

This is a high-priority feature for v1.1.0 as it completes the notification system alongside the existing in-app and Telegram notifications. The foundation is already in place, so this is primarily about enabling and integrating existing components with the new scheduler.

Operating System

All (server-side feature)

Browser

All

Version

v1.0.0-rc.3 (targeting v1.1.0)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status
Q2 2026

Relationships

None yet

Development

No branches or pull requests

Issue actions