Skip to content

feat(notifications): recipient-scoped delivery with mute and block preferences#404

Open
Varshinibhargav-17 wants to merge 1 commit into
c2siorg:developfrom
Varshinibhargav-17:feat/recipient-scoped-notifications
Open

feat(notifications): recipient-scoped delivery with mute and block preferences#404
Varshinibhargav-17 wants to merge 1 commit into
c2siorg:developfrom
Varshinibhargav-17:feat/recipient-scoped-notifications

Conversation

@Varshinibhargav-17
Copy link
Copy Markdown

Summary

Implements recipient-scoped notifications with mute/block preferences,
fixing the architectural issues described in #359.

Problem

The existing notification system stored all notifications in a shared
flat collection with no recipient scoping. getNotificationData fetched
ALL notifications globally, read/delete operations used the flat
collection path, and the Block user UI button in NotificationBox.jsx
had no implementation.

Changes Made

Firestore structure:
Notifications are now stored at notifications/{uid}/userNotifications/{notification_id}
— one subcollection per user, fully recipient-scoped.

addNotification:

  • Now accepts recipient_uid parameter
  • Checks notification_preferences/{uid}.blockedUsers before creating
    notification — skips delivery if sender is blocked
  • Stores recipient_uid and type fields in notification document

getNotificationData:

  • Now accepts uid parameter
  • Fetches only notifications/{uid}/userNotifications — no more
    global fetch

readNotification / deleteNotification:

  • Updated to use subcollection path with uid

blockUser action (new):

  • Writes username to notification_preferences/{uid}.blockedUsers
    via arrayUnion
  • Future notifications from blocked user are silently skipped

muteUser action (new):

  • Writes username to notification_preferences/{uid}.mutedUsers
    via arrayUnion

NotificationBox.jsx:

  • Block button now calls blockUser action
  • Added Mute button calling muteUser action
  • Both use firebase.auth().currentUser?.uid for safety

dataReducer.js:

  • Added blockedUsers and mutedUsers to initial state
  • BLOCK_USER_SUCCESS filters blocked user's notifications from state
  • MUTE_USER_SUCCESS adds to mutedUsers list

actionTypes.js:

  • Added BLOCK_USER_START/SUCCESS/FAIL
  • Added MUTE_USER_START/SUCCESS/FAIL
  • Added GET_BLOCKED_USERS_SUCCESS

Testing

  • npm run build — 0 errors
  • npm run dev — app loads correctly
  • Block button in notification menu now functional
  • Mute button added alongside Block

Fixes #359

…te/block preferences

- Scope notifications to recipient using notifications/{uid}/userNotifications subcollection
- Add recipient_uid field to notification documents
- Fix getNotificationData to fetch only current user's notifications
- Check notification_preferences before creating notification (skip if sender is blocked)
- Add blockUser action — writes to notification_preferences/{uid}.blockedUsers
- Add muteUser action — writes to notification_preferences/{uid}.mutedUsers
- Update readNotification and deleteNotification to use subcollection path
- Add BLOCK_USER, MUTE_USER, GET_BLOCKED_USERS action types
- Update dataReducer to handle blockedUsers and mutedUsers state
- Wire up Block and Mute buttons in NotificationBox.jsx

Fixes c2siorg#359
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.

Implement recipient-scoped notifications with mute/block preferences

1 participant