DevByte-Community / DevByte-Community/Community-API-Backend

Implement Basic Notification System (V1)

Aperta
#72 0 commenti 0 reazioni 1 assegnatario Rivendicata da @marrious11 Vedi su GitHub
Lingua principale
JavaScript
Stelle
2
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Ticket ID: NOTIF-SYSTEM-001
Priority: Medium

**Feature Description**

Implement a simple notification system that stores and retrieves user notifications based on platform activities. Notifications will be stored in the database and retrieved via API. Users can view, mark as read, and delete notifications.

**Acceptance Criteria**

1. Database Schema ✅

- Create new table:
```
sql

notifications
- id: uuidv7 PRIMARY KEY
- user_id: uuid REFERENCES users(id) ON DELETE CASCADE
- type: VARCHAR(20) -- 'SYSTEM', 'PROJECT', 'EVENT', 'BLOG'
- title: VARCHAR(100)
- message: TEXT
- entity_type: VARCHAR(50) -- 'project', 'event', 'blog', etc.
- entity_id: uuid
- is_read: BOOLEAN DEFAULT false
- created_at: TIMESTAMP DEFAULT NOW()
```

2. Core Notifications (MVP) ✅

- Trigger notifications for:

- Project: User added as contributor, project status changes

- Event: User registered for event, event starting soon (24h)

- Blog: User's blog post is published/commented on

- System: Platform announcements (admin only)

3. API Endpoints ✅
```
text

GET /api/notifications # List notifications (paginated, 20/page)
GET /api/notifications/unread-count # Get unread count for header badge
PUT /api/notifications/:id/read # Mark single as read
PUT /api/notifications/read-all # Mark all user's notifications as read
DELETE /api/notifications/:id # Delete single notification
DELETE /api/notifications # Delete all user's notifications
```

4. Response Format ✅
```
json

{
"success"" true,
"notifications": [
{
"id": "uuid",
"type": "PROJECT",
"title": "Added to Project",
"message": "You were added as a contributor to 'E-commerce Platform'",
"entityType": "project",
"entityId": "project-uuid",
"isRead": false,
"createdAt": "2024-01-15T10:30:00Z",
"metadata": {}
}
],
"total": 45,
"unreadCount": 12,
"page": 1,
"pageSize": 1
...
}
```

5. Filtering & Preferences ✅

- Show all notification types if user preference notification field is true

- Admin system notifications always shown

6. Performance Requirements ✅

- API response time < 100ms

- Indexes on: user_id, is_read, created_at

- Pagination using cursor-based or offset pagination

- Cleanup old notifications (> 90 days) via scheduled job

7. Testing ✅

- Unit tests for notification creation

- Integration tests for API endpoints

- Test preference filtering logic

- Test pagination and ordering (newest first)

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.