Skip to content

Conversation

@LaGodxy
Copy link
Contributor

@LaGodxy LaGodxy commented Jun 5, 2025

📌 Pull Request Title

feat(notification-preference): add customizable notification preference management per user

Description

This PR implements a comprehensive notification preference system that allows users (students, tutors, admins) to customize what types of notifications they want to receive and through which channels. The system integrates with the existing notification service to filter notifications based on user preferences.

Related Issues

Closes #88 - Add notification preference management

Changes Made

  • Created NotificationPreference entity with fields for all notification categories and delivery channels
  • Implemented CRUD operations in NotificationPreferenceService
  • Added REST endpoints in NotificationPreferenceController for managing preferences
  • Integrated with existing NotificationService to respect user preferences
  • Added support for quiet hours with timezone handling
  • Implemented automatic creation of default preferences for new users
  • Added comprehensive test coverage (unit, integration, e2e)
  • Updated app module to include the new module

How to Test

Use the following HTTPYac file to test the endpoints:

@baseUrl = http://localhost:3000
@studentEmail = [email protected]
@studentPassword = Password123!
@tutorEmail = [email protected]
@tutorPassword = Password123!
@adminEmail = [email protected]
@adminPassword = Password123!

### 1. Create Test Users

### Create Student User
# @name createStudent
POST {{baseUrl}}/auth/register
Content-Type: application/json

{
  "email": "{{studentEmail}}",
  "password": "{{studentPassword}}",
  "firstName": "Test",
  "lastName": "Student",
  "role": "STUDENT"
}

### Create Tutor User
# @name createTutor
POST {{baseUrl}}/auth/register
Content-Type: application/json

{
  "email": "{{tutorEmail}}",
  "password": "{{tutorPassword}}",
  "firstName": "Test",
  "lastName": "Tutor",
  "role": "TUTOR"
}

### 2. Login and Get Tokens

### Login as Student
# @name loginStudent
POST {{baseUrl}}/auth/login
Content-Type: application/json

{
  "email": "{{studentEmail}}",
  "password": "{{studentPassword}}"
}

@studentToken = {{loginStudent.response.body.accessToken}}

### Login as Tutor
# @name loginTutor
POST {{baseUrl}}/auth/login
Content-Type: application/json

{
  "email": "{{tutorEmail}}",
  "password": "{{tutorPassword}}"
}

@tutorToken = {{loginTutor.response.body.accessToken}}

### 3. Test Notification Preferences

### Get Student Notification Preferences
GET {{baseUrl}}/notification-preferences
Authorization: Bearer {{studentToken}}

### Update Student Notification Preferences
PUT {{baseUrl}}/notification-preferences
Authorization: Bearer {{studentToken}}
Content-Type: application/json

{
  "lessonUpdates": false,
  "quizResults": true,
  "viaEmail": true,
  "viaInApp": true,
  "quietHoursStart": "22:00",
  "quietHoursEnd": "08:00",
  "timezone": "America/New_York"
}

### Reset Student Notification Preferences to Default
POST {{baseUrl}}/notification-preferences/reset
Authorization: Bearer {{studentToken}}

### Delete Student Notification Preferences
DELETE {{baseUrl}}/notification-preferences
Authorization: Bearer {{studentToken}}

### Get Tutor Notification Preferences
GET {{baseUrl}}/notification-preferences
Authorization: Bearer {{tutorToken}}

### Update Tutor Notification Preferences
PUT {{baseUrl}}/notification-preferences
Authorization: Bearer {{tutorToken}}
Content-Type: application/json

{
  "courseEnrollment": true,
  "daoUpdates": false,
  "viaEmail": false,
  "viaInApp": true
}

Checklist

  • My code follows the project's coding style.
  • I have tested these changes locally.
  • Documentation has been updated where necessary.
  • Added proper validation for all DTOs
  • Ensured backward compatibility with existing notification system
  • Added proper error handling and HTTP status codes
  • Implemented security measures to prevent unauthorized access

@portableDD portableDD merged commit e7510f4 into Nexacore-Org:main Jun 5, 2025
3 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

Development

Successfully merging this pull request may close these issues.

Implement Notification Preferences Module

2 participants