about summary refs log tree commit diff
path: root/app/policies/account_policy.rb
blob: a744af81ded5941b09551145cc2249b6bf44d1b1 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true

class AccountPolicy < ApplicationPolicy
  def index?
    role.can?(:manage_users)
  end

  def show?
    role.can?(:manage_users)
  end

  def warn?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  end

  def suspend?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role) && !record.instance_actor?
  end

  def destroy?
    record.suspended_temporarily? && role.can?(:delete_user_data)
  end

  def unsuspend?
    role.can?(:manage_users) && record.suspension_origin_local?
  end

  def sensitive?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  end

  def unsensitive?
    role.can?(:manage_users)
  end

  def silence?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  end

  def unsilence?
    role.can?(:manage_users)
  end

  def redownload?
    role.can?(:manage_federation)
  end

  def remove_avatar?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  end

  def remove_header?
    role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  end

  def memorialize?
    role.can?(:delete_user_data) && role.overrides?(record.user_role) && !record.instance_actor?
  end

  def unblock_email?
    role.can?(:manage_users)
  end

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