Skip to content

[Backend] — Bug/Test: NotificationsService.markAsRead silently ignores wrong-owner updates #1099

Description

@Olowodarey

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

  1. In NotificationsService.markAsRead, update to:

  2. Add tests in src/notifications/notifications.service.spec.ts:

    • Correct owner: result.affected = 1 → no error, broadcaster called.
    • Wrong owner: result.affected = 0NotFoundException.

Acceptance criteria

  • Marking another user's notification throws 404.
  • Correct notification marked and broadcaster called.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions