# frozen_string_literal: true
class StatusPolicy
attr_reader :account, :status
def initialize(account, status)
@account = account
@status = status
end
def show?
if direct?
owned? || status.mentions.where(account: account).exists?
elsif private?
owned? || account&.following?(status.account) || status.mentions.where(account: account).exists?
else
account.nil? || !status.account.blocking?(account)
def reblog?
!direct? && !private? && show?
def destroy?
admin? || owned?
alias unreblog? destroy?
private
def admin?
account&.user&.admin?
def direct?
status.direct_visibility?
def owned?
status.account.id == account&.id
def private?
status.private_visibility?