about summary refs log tree commit diff
path: root/app/models/stream_entry.rb
blob: e19dcc6c6d010dcf626d996e72d51f832e2f8f6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class StreamEntry < ActiveRecord::Base
  belongs_to :account, inverse_of: :stream_entries
  belongs_to :activity, polymorphic: true

  validates :account, :activity, presence: true

  def object_type
    targeted? ? :activity : self.activity.object_type
  end

  def verb
    self.activity.verb
  end

  def targeted?
    [:follow, :share, :favorite].include? verb
  end

  def target
    self.activity.target
  end

  def title
    self.activity.title
  end

  def content
    self.activity.content
  end

  def threaded?
    verb == :favorite || object_type == :comment
  end

  def thread
    self.activity.thread
  end

  def mentions
    self.activity.mentions
  end
end