~cytrogen/masto-fe

ref: b83e487502d2c6cd5027c27dec6f056de8a90d1c masto-fe/app/policies/admin/status_policy.rb -rw-r--r-- 776 bytes
b83e4875 — Claire Fix moderator rights inconsistencies (#26729) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class Admin::StatusPolicy < ApplicationPolicy
  def initialize(current_account, record, preloaded_relations = {})
    super(current_account, record)

    @preloaded_relations = preloaded_relations
  end

  def index?
    role.can?(:manage_reports, :manage_users)
  end

  def show?
    role.can?(:manage_reports, :manage_users) && (record.public_visibility? || record.unlisted_visibility? || record.reported? || viewable_through_normal_policy?)
  end

  def destroy?
    role.can?(:manage_reports)
  end

  def update?
    role.can?(:manage_reports)
  end

  def review?
    role.can?(:manage_taxonomies)
  end

  private

  def viewable_through_normal_policy?
    StatusPolicy.new(current_account, record, @preloaded_relations).show?
  end
end