mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 05:55:19 +01:00
7bb8b0b2fc
* Add moderator role and add pundit policies for admin actions * Add rake task for turning user into mod and revoking it again * Fix handling of unauthorized exception * Deliver new report e-mails to staff, not just admins * Add promote/demote to admin UI, hide some actions conditionally * Fix unused i18n
50 lines
792 B
Ruby
50 lines
792 B
Ruby
# frozen_string_literal: true
|
|
|
|
class StatusPolicy < ApplicationPolicy
|
|
def index?
|
|
staff?
|
|
end
|
|
|
|
def show?
|
|
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
|
|
end
|