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

Implement Basic Notification System (V1)

Đang mở
#72 0 bình luận 0 reaction 1 người được giao Được @marrious11 nhận Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.