Module: Diaspora::MentionsContainer

Extended by:
ActiveSupport::Concern
Included in:
Comment, Post
Defined in:
lib/diaspora/mentions_container.rb

Instance Method Summary collapse

Instance Method Details

#add_mention_subscribers?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/diaspora/mentions_container.rb', line 20

def add_mention_subscribers?
  public?
end

#create_mentionsObject


30
31
32
33
34
# File 'lib/diaspora/mentions_container.rb', line 30

def create_mentions
  Diaspora::Mentionable.people_from_string(text).each do |person|
    mentions.find_or_create_by(person_id: person.id)
  end
end

#mentioned_peopleObject


12
13
14
15
16
17
18
# File 'lib/diaspora/mentions_container.rb', line 12

def mentioned_people
  if persisted?
    mentions.includes(person: :profile).map(&:person)
  else
    Diaspora::Mentionable.people_from_string(text)
  end
end

#messageObject


36
37
38
# File 'lib/diaspora/mentions_container.rb', line 36

def message
  @message ||= Diaspora::MessageRenderer.new text, mentioned_people: mentioned_people
end

#subscribersObject


24
25
26
27
28
# File 'lib/diaspora/mentions_container.rb', line 24

def subscribers
  super.tap {|subscribers|
    subscribers.concat(mentions.map(&:person).select(&:remote?)) if add_mention_subscribers?
  }
end