Skip to content

feat(notifications): add bulk read/unread endpoints (#1388) - #1492

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
iyanumajekodunmi756:feat/1388-bulk-notification-read-unread
Jul 29, 2026
Merged

feat(notifications): add bulk read/unread endpoints (#1388)#1492
Olowodarey merged 1 commit into
Arena1X:mainfrom
iyanumajekodunmi756:feat/1388-bulk-notification-read-unread

Conversation

@iyanumajekodunmi756

@iyanumajekodunmi756 iyanumajekodunmi756 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1388 — Bulk Notification Read/Unread Endpoints.

Users can now mark lists of notifications (or all notifications) as read or unread in a single request, eliminating N+1 round-trips caused by marking notifications one at a time.

Changes

New Endpoints

Method Endpoint Description
PATCH /notifications/bulk/read Mark a list of notification IDs as read
PATCH /notifications/bulk/unread Mark a list of notification IDs as unread
PATCH /notifications/unread-all Mark all notifications as unread

Modified Endpoints

Method Endpoint Change
PATCH /notifications/read-all Now returns { unreadCount: 0 } instead of { updated: N }

Design Decisions

  • Idempotent: Marking already-read notifications as read (or unread as unread) has no effect — the operation can be repeated safely
  • User-scoped: All operations are gated by JwtAuthGuard and filtered by user.stellar_address — users can only modify their own notifications
  • Returns unreadCount: Every bulk/mark-all operation returns the updated unread count in the response body
  • Route ordering fix: Static routes (read-all, unread-all, bulk/read, bulk/unread) are defined before the parameterized :id/read route to prevent NestJS from incorrectly matching bulk as an :id parameter
  • Empty array handling: Sending an empty notificationIds array is a graceful no-op (no DB call made)
  • DTO validation: BulkUpdateDto validates that all IDs are positive integers using class-validator decorators

Files Changed

File Change
backend/src/notifications/dto/bulk-update.dto.ts New — DTO with validated notificationIds: number[]
backend/src/notifications/notifications.service.ts Added markAllAsUnread, markMultipleAsUnread; updated markAllAsRead & markMultipleAsRead to return { unreadCount }
backend/src/notifications/notifications.controller.ts Added 3 new endpoints + route reorder fix
backend/src/notifications/notifications.service.spec.ts 14 new tests: bulk/mark-all read & unread, idempotency, empty arrays, user scoping
backend/src/notifications/notifications.controller.spec.ts 6 new tests for the 4 new/updated controller endpoints

Acceptance Criteria

  • Bulk and mark-all update only the caller's notifications
  • The response includes the updated unread count
  • Repeating the operation is idempotent
  • Tests cover bulk, mark-all, and scoping

Test Results

PASS src/notifications/digest.service.spec.ts
PASS src/notifications/notifications.controller.spec.ts
PASS src/notifications/notifications.service.spec.ts
PASS src/notifications/email.service.spec.ts
PASS src/notifications/notification-generator.service.spec.ts

Test Suites: 5 passed, 5 total
Tests:       115 passed, 115 total

No regressions. All existing notification tests continue to pass.

API Examples

Bulk mark as read

PATCH /notifications/bulk/read
Authorization: Bearer <token>
Content-Type: application/json

{
  "notificationIds": [1, 2, 3]
}

Response (200):

{ unreadCount: 5 }

Bulk mark as unread

PATCH /notifications/bulk/unread
Authorization: Bearer <token>
Content-Type: application/json

{
  "notificationIds": [4, 5]
}

Response (200):

{ unreadCount: 7 }

Mark all as unread

PATCH /notifications/unread-all
Authorization: Bearer <token>

Response (200):

{ unreadCount: 12 }

Closes #1388

- Add POST /notifications/bulk/read to mark a list of notifications as read
- Add POST /notifications/bulk/unread to mark a list as unread
- Add POST /notifications/unread-all to mark all notifications as unread
- Update POST /notifications/read-all to return unreadCount instead of updated
- All operations are idempotent and scoped to the authenticated user
- Add BulkUpdateDto with validation for notification IDs
- Add comprehensive unit tests covering bulk, mark-all, scoping, and
  idempotency for both read and unread operations
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jul 29, 2026 7:54am

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@iyanumajekodunmi756 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Olowodarey
Olowodarey merged commit 5330642 into Arena1X:main Jul 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] — Bulk Notification Read/Unread Endpoint

2 participants