Class: Decidim::EnhancedTextwork::NotifyParagraphsMentionedJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/enhanced_textwork/notify_paragraphs_mentioned_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(comment_id, linked_paragraphs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/jobs/decidim/enhanced_textwork/notify_paragraphs_mentioned_job.rb', line 6

def perform(comment_id, linked_paragraphs)
  comment = Decidim::Comments::Comment.find(comment_id)

  linked_paragraphs.each do |paragraph_id|
    paragraph = Paragraph.find(paragraph_id)
    affected_users = paragraph.notifiable_identities

    Decidim::EventsManager.publish(
      event: "decidim.events.enhanced_textwork.paragraph_mentioned",
      event_class: Decidim::EnhancedTextwork::ParagraphMentionedEvent,
      resource: comment.root_commentable,
      affected_users: affected_users,
      extra: {
        comment_id: comment.id,
        mentioned_paragraph_id: paragraph_id
      }
    )
  end
end