Class: Decidim::Proposals::NotifyProposalsMentionedJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(comment_id, proposal_metadata) ⇒ Object



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

def perform(comment_id, )
  comment = Decidim::Comments::Comment.find(comment_id)
  linked_proposals = .linked_proposals
  linked_proposals.each do |proposal_id|
    proposal = Proposal.find(proposal_id)
    next if proposal.decidim_author_id.blank?

    recipient_ids = [proposal.decidim_author_id]
    Decidim::EventsManager.publish(
      event: "decidim.events.proposals.proposal_mentioned",
      event_class: Decidim::Proposals::ProposalMentionedEvent,
      resource: comment.root_commentable,
      recipient_ids: recipient_ids,
      extra: {
        comment_id: comment.id,
        mentioned_proposal_id: proposal_id
      }
    )
  end
end