Module: Notifications::Mentioned::ClassMethods

Defined in:
app/models/notifications/mentioned.rb

Instance Method Summary collapse

Instance Method Details

#notify(mentionable, recipient_user_ids) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/notifications/mentioned.rb', line 12

def notify(mentionable, recipient_user_ids)
  actor = mentionable.author
  relevant_mentions = filter_mentions(
    mentionable.mentions.local.where.not(person: actor),
    mentionable,
    recipient_user_ids
  )

  relevant_mentions.each do |mention|
    recipient = mention.person.owner
    unless exists?(recipient: recipient, target: mention)
      create_notification(recipient, mention, actor).try(:email_the_user, mention, actor)
    end
  end
end