mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 21:38:07 +01:00
f6355f6ffb
StatusPolicy#account was renamed to StatusPolicy#current_account in upstream. This commit renames the local-only changes to match and augments the #show? policy spec with what we expect for local-only toots.
55 lines
899 B
Ruby
55 lines
899 B
Ruby
# frozen_string_literal: true
|
|
|
|
class StatusPolicy < ApplicationPolicy
|
|
def index?
|
|
staff?
|
|
end
|
|
|
|
def show?
|
|
return false if local_only? && current_account.nil?
|
|
|
|
if direct?
|
|
owned? || record.mentions.where(account: current_account).exists?
|
|
elsif private?
|
|
owned? || current_account&.following?(author) || record.mentions.where(account: current_account).exists?
|
|
else
|
|
current_account.nil? || !author.blocking?(current_account)
|
|
end
|
|
end
|
|
|
|
def reblog?
|
|
!direct? && !private? && show?
|
|
end
|
|
|
|
def destroy?
|
|
staff? || owned?
|
|
end
|
|
|
|
alias unreblog? destroy?
|
|
|
|
def update?
|
|
staff?
|
|
end
|
|
|
|
private
|
|
|
|
def direct?
|
|
record.direct_visibility?
|
|
end
|
|
|
|
def owned?
|
|
author.id == current_account&.id
|
|
end
|
|
|
|
def private?
|
|
record.private_visibility?
|
|
end
|
|
|
|
def author
|
|
record.account
|
|
end
|
|
|
|
def local_only?
|
|
record.local_only?
|
|
end
|
|
end
|