Class: Decidim::Comments::NewCommentNotificationCreator
- Inherits:
-
Object
- Object
- Decidim::Comments::NewCommentNotificationCreator
- Defined in:
- app/services/decidim/comments/new_comment_notification_creator.rb
Overview
This class handles what events must be triggered, and to what users, after a comment is created. Handles these cases:
-
A user is mentioned in the comment
-
My comment is replied
-
A user I’m following has created a comment/reply
-
A new comment has been created on a resource, and I should be notified.
A given user will only receive one of these notifications, for a given comment. If need be, the code to handle this cases can be swapped easily.
Instance Method Summary collapse
-
#create ⇒ Object
Generates the notifications for the given comment.
-
#initialize(comment, mentioned_users) ⇒ NewCommentNotificationCreator
constructor
comment - the Comment from which to generate notifications.
Constructor Details
#initialize(comment, mentioned_users) ⇒ NewCommentNotificationCreator
comment - the Comment from which to generate notifications. mentioned_users - An ActiveRecord::Relation of the users that have been
mentioned
19 20 21 22 23 |
# File 'app/services/decidim/comments/new_comment_notification_creator.rb', line 19 def initialize(comment, mentioned_users) @comment = comment @mentioned_users = mentioned_users @already_notified_ids = [] end |
Instance Method Details
#create ⇒ Object
Generates the notifications for the given comment.
Returns nothing.
28 29 30 31 32 33 |
# File 'app/services/decidim/comments/new_comment_notification_creator.rb', line 28 def create notify_mentioned_users notify_commentable_recipients end |