Skip to content

Feat: #2748 (Backend) IdeaSpace Comment Notifications#326

Open
tanmaydhal wants to merge 1 commit into
mainfrom
2748-toastNotifications
Open

Feat: #2748 (Backend) IdeaSpace Comment Notifications#326
tanmaydhal wants to merge 1 commit into
mainfrom
2748-toastNotifications

Conversation

@tanmaydhal

Copy link
Copy Markdown

NOTE

Mark Notifications as Read should be implemented alongside this feature. Otherwise these toasts will get noisy very quickly

Background

This PR is 1 of 2 PR's. This implements backend changes for #2748. This should be merged BEFORE the Frontend PR.

Summary

Implements the backend notification logic for comment activity on ideas. When a user comments on an idea, the relevant users are notified via the existing event/notification/subscription model.

Changes

comment/content-types/comment/lifecycles.js

  • Added afterCreate lifecycle hook to handle notification creation when a comment is posted
  • Fetches the idea owner and existing subscribers for the idea
  • Builds a set of users to notify, explicitly excluding the commenter (no self-notifications)
  • Creates a subscription for the commenter if one doesn't already exist
  • Creates a single event record and one notification per user to notify

event/content-types/event/lifecycles.js

  • Added a guard to skip automatic notification creation for comment events (action === "Commented" or entityType === "Comment")
  • This prevents duplicate notifications since comment notifications are handled entirely in comment/lifecycles.js

Testing

  • Tested locally using two accounts: one as idea owner, one as commenter. Verified in Strapi admin that exactly 1 notification is created for the correct user with no duplicates or self-notifications.

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.

1 participant