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

Implement Basic Notification System (V1)

未关闭
#72 0 条评论 0 个 reaction 已指派 1 人 已被 @marrious11 认领 在 GitHub 查看
主要语言
JavaScript
星标
2
派生
11
PR 合并指标
30 天内没有已合并 PR

描述

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)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。