blob: 3521247e834fc5e1ebfcf01f61923e5aabfdba31 (
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
|
class Follow < ActiveRecord::Base
belongs_to :account
belongs_to :target_account, class_name: 'Account'
has_one :stream_entry, as: :activity, dependent: :destroy
validates :account, :target_account, presence: true
validates :account_id, uniqueness: { scope: :target_account_id }
def verb
self.destroyed? ? :unfollow : :follow
end
def target
self.target_account
end
def object_type
target.object_type
end
def content
self.destroyed? ? "#{self.account.acct} is no longer following #{self.target_account.acct}" : "#{self.account.acct} started following #{self.target_account.acct}"
end
def title
content
end
def mentions
[]
end
after_create do
self.account.stream_entries.create!(activity: self)
end
end
|