Skip to content

Implement Notification Service #382

@Ziadsharkos

Description

@Ziadsharkos

As a Sporta User, I want to receive real-time notifications for events such as event cancellations, friend requests, and friend request acceptances so that I can stay informed about important updates in the application.

Story Points: 8
Priority: High
Risk: High
Child of: #1

Task Breakdown:

  1. Create Notification Entity and Repository:
  • Define the Notification entity with fields: id, userId, message, type, createdAt, isRead.

  • Create NotificationRepository for CRUD operations.

  1. Implement Notification Service:
  • Add methods to send, fetch, and mark notifications as read.

  • Use SimpMessagingTemplate to send real-time notifications via WebSocket.

  1. Integrate with Existing Services:
  • Modify UserServiceImpl to send notifications for friend requests and acceptances.

  • Modify EventServiceImpl to send notifications for event cancellations.

  1. Add REST Endpoints:
  • Create NotificationController with endpoints:

  • GET /notifications/{userId}: Fetch all notifications for a user.

  • GET /notifications/{userId}/unread: Fetch unread notifications for a user.

PATCH /notifications/{notificationId}/read: Mark a notification as read.

Acceptance Criteria:

  • Notifications are sent to users when:
  1. An event they are registered for is cancelled.

  2. They receive a friend request.

  3. Their friend request is accepted.

  • Notifications are stored in the database and can be fetched via REST API.

  • Real-time notifications are delivered to users via WebSocket.

  • Users can mark notifications as read.

Blackbox Testing:

  1. Verify that notifications are sent when:
  • An event is cancelled.

  • A friend request is sent.

  • A friend request is accepted.

  1. Verify that notifications are stored in the database and can be fetched via REST API.

  2. Verify that real-time notifications are delivered to the frontend via WebSocket.

  3. Verify that users can mark notifications as read.

Regression Testing:

  1. Ensure that existing functionality (e.g., event management, friend requests) is not broken after integrating the notification service.

  2. Test the performance impact of sending real-time notifications.

Precondition:

  • To be successfully logged in to your Sporta account with a valid username and password.

Demo Steps:

  1. Send a Friend Request:
  • Log in as User A.
  • Send a friend request to User B.
  • Verify that User B receives a real-time notification.
  1. Accept a Friend Request:
  • Log in as User B.
  • Accept the friend request from User A.
  • Verify that User A receives a real-time notification.
  1. Cancel an Event:
  • Log in as an event organizer.
  • Cancel an event that User A is registered for.
  • Verify that User A receives a real-time notification.
  1. Mark Notifications as Read:
  • Log in as User A.
  • View notifications and mark them as read.
  • Verify that the notifications are marked as read in the database.
  1. Fetch Notifications via REST API:
  • Use the REST API to fetch all notifications and unread notifications for User A.
  • Verify that the correct notifications are returned.

Metadata

Metadata

Labels

backendBackend related, server side
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions