blob: 41d63fcbcbca047b8cae40dfa408984e9ea8439f (
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
|
# frozen_string_literal: true
class StatusPolicy
attr_reader :account, :status
def initialize(account, status)
@account = account
@status = status
end
def show?
if direct?
status.account.id == account&.id || status.mentions.where(account: account).exists?
elsif private?
status.account.id == account&.id || account&.following?(status.account) || status.mentions.where(account: account).exists?
else
account.nil? || !status.account.blocking?(account)
end
end
def reblog?
!direct? && !private? && show?
end
private
def direct?
status.direct_visibility?
end
def private?
status.private_visibility?
end
end
|