Feature/notification preferences issue 29#39
Open
Phantomcall wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notification Preferences API
This pull request implements the Notification Preferences API, enabling users to control their notification preferences independently. It includes the database schema, entity mappings, REST API endpoints, user signup hooks, comprehensive unit testing, and API documentation.
Proposed Changes
1. Database Schema & Migration
NotificationPreference(notification_preferencestable) with the following fields:id: Auto-generated primary key (identity).userId:intlinked to theUserentity via a one-to-one relationship (onDelete: 'CASCADE'). Indexed for query performance.newSubscriber:boolean, defaulttrue.postFromSubscribedCreator:boolean, defaulttrue.securityAlerts:boolean, defaulttrue.marketing:boolean, defaultfalse.created_at/updated_at: Timestamps.1769050000000-CreateNotificationPreferences.tswith correct defaults and constraints.2. REST Endpoints (
/users/me/notification-preferences)400 Bad Requestexception.JwtAuthGuardand utilize theAuthenticatedRequestcontext.3. User Signup Integration Hook
UsersService.createUserto automatically create default notification preferences immediately upon successful signup.4. Service Helper (
shouldNotify)NotificationsService.shouldNotify(userId, eventType)for other system modules to query if they should deliver notifications for events like:newSubscriberpostFromSubscribedCreatorsecurityAlertsmarketingBadRequestException.5. Code Quality & Testing
notifications.service.spec.tsandnotifications.controller.spec.ts.unbound-methoderrors and adding type assertions for mock requests/arguments).closes #29