Background
NotificationsService.markAsRead (src/notifications/notifications.service.ts)
calls this.notificationsRepository.update({ id, user_address }, { read: true }).
When id exists but user_address doesn't match, result.affected is 0 but no
error is thrown. A client that guesses a notification ID from another user would
get a silent success.
Goal
Throw NotFoundException when affected == 0.
Requirements
-
In NotificationsService.markAsRead, update to:
-
Add tests in src/notifications/notifications.service.spec.ts:
- Correct owner:
result.affected = 1 → no error, broadcaster called.
- Wrong owner:
result.affected = 0 → NotFoundException.
Acceptance criteria
- Marking another user's notification throws
404.
- Correct notification marked and broadcaster called.
Background
NotificationsService.markAsRead(src/notifications/notifications.service.ts)calls
this.notificationsRepository.update({ id, user_address }, { read: true }).When
idexists butuser_addressdoesn't match,result.affectedis 0 but noerror is thrown. A client that guesses a notification ID from another user would
get a silent success.
Goal
Throw
NotFoundExceptionwhenaffected == 0.Requirements
In
NotificationsService.markAsRead, update to:Add tests in
src/notifications/notifications.service.spec.ts:result.affected = 1→ no error, broadcaster called.result.affected = 0→NotFoundException.Acceptance criteria
404.