about summary refs log tree commit diff
path: root/app/policies/account_policy.rb
blob: 3ac0c4c6a4b3878bbc6f845b8d9012953c357249 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# frozen_string_literal: true

class AccountPolicy < ApplicationPolicy
  def index?
    !defanged? && can_moderate?
  end

  def show?
    !defanged? && can_moderate?
  end

  def warn?
    !defanged? && staff? && has_more_authority_than?(record&.user)
  end

  def mark_known?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def mark_unknown?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def manual_only?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def auto_trust?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def suspend?
    !defanged? && staff? && has_more_authority_than?(record&.user)
  end

  def unsuspend?
    !defanged? && staff? && has_more_authority_than?(record&.user)
  end

  def silence?
    !defanged? && can_moderate? && has_more_authority_than?(record.user)
  end

  def unsilence?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def force_unlisted?
    !defanged? && staff? && has_more_authority_than?(record&.user)
  end

  def allow_public?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def force_sensitive?
    !defanged? && staff? && has_more_authority_than?(record&.user)
  end

  def allow_nonsensitive?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def redownload?
    !defanged? && can_moderate?
  end

  def sync?
    !defanged? && can_moderate?
  end

  def remove_avatar?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def remove_header?
    !defanged? && can_moderate? && has_more_authority_than?(record&.user)
  end

  def subscribe?
    !defanged? && admin?
  end

  def unsubscribe?
    !defanged? && admin?
  end

  def memorialize?
    !defanged? && staff? && !record.user&.staff?
  end
end