blob: a6a050ce1d832559f1c85435cf49155ee49cacc8 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# frozen_string_literal: true
class StatusFilter
attr_reader :status, :account
def initialize(status, account)
@status = status
@account = account
end
def filtered?
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
end
private
def account_present?
!account.nil?
end
def filtered_status?
blocking_account? || blocking_domain? || muting_account?
end
def blocking_account?
account.blocking? status.account_id
end
def blocking_domain?
account.domain_blocking? status.account_domain
end
def muting_account?
account.muting? status.account_id
end
def silenced_account?
!account&.silenced? && status_account_silenced? && !account_following_status_account?
end
def status_account_silenced?
status.account.silenced?
end
def account_following_status_account?
account&.following? status.account_id
end
def blocked_by_policy?
!policy_allows_show?
end
def policy_allows_show?
StatusPolicy.new(account, status).show?
end
end
|