Move status reblog authorization into policy (#3425)
This commit is contained in:
parent
bc4fad9e22
commit
e031fd60ad
3 changed files with 42 additions and 11 deletions
|
@ -9,12 +9,26 @@ class StatusPolicy
|
|||
end
|
||||
|
||||
def show?
|
||||
if status.direct_visibility?
|
||||
if direct?
|
||||
status.account.id == account&.id || status.mentions.where(account: account).exists?
|
||||
elsif status.private_visibility?
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue