Move status reblog authorization into policy (#3425)

This commit is contained in:
Jack Jennings 2017-05-30 06:16:14 -07:00 committed by Eugen Rochko
parent bc4fad9e22
commit e031fd60ad
3 changed files with 42 additions and 11 deletions

View file

@ -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