account_policy.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # frozen_string_literal: true
  2. class AccountPolicy < ApplicationPolicy
  3. def index?
  4. role.can?(:manage_users)
  5. end
  6. def show?
  7. role.can?(:manage_users)
  8. end
  9. def warn?
  10. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  11. end
  12. def suspend?
  13. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role) && !record.instance_actor?
  14. end
  15. def destroy?
  16. record.suspended_temporarily? && role.can?(:delete_user_data)
  17. end
  18. def unsuspend?
  19. role.can?(:manage_users) && record.suspension_origin_local?
  20. end
  21. def sensitive?
  22. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  23. end
  24. def unsensitive?
  25. role.can?(:manage_users)
  26. end
  27. def silence?
  28. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  29. end
  30. def unsilence?
  31. role.can?(:manage_users)
  32. end
  33. def redownload?
  34. role.can?(:manage_federation)
  35. end
  36. def remove_avatar?
  37. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  38. end
  39. def remove_header?
  40. role.can?(:manage_users, :manage_reports) && role.overrides?(record.user_role)
  41. end
  42. def memorialize?
  43. role.can?(:delete_user_data) && role.overrides?(record.user_role) && !record.instance_actor?
  44. end
  45. def unblock_email?
  46. role.can?(:manage_users)
  47. end
  48. def review?
  49. role.can?(:manage_taxonomies)
  50. end
  51. end