You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class AccountsController < BaseController
  4. before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :enable, :disable, :memorialize]
  5. before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
  6. before_action :require_local_account!, only: [:enable, :disable, :memorialize]
  7. def index
  8. @accounts = filtered_accounts.page(params[:page])
  9. end
  10. def show
  11. @account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
  12. @moderation_notes = @account.targeted_moderation_notes.latest
  13. end
  14. def subscribe
  15. Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
  16. redirect_to admin_account_path(@account.id)
  17. end
  18. def unsubscribe
  19. Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
  20. redirect_to admin_account_path(@account.id)
  21. end
  22. def memorialize
  23. @account.memorialize!
  24. redirect_to admin_account_path(@account.id)
  25. end
  26. def enable
  27. @account.user.enable!
  28. redirect_to admin_account_path(@account.id)
  29. end
  30. def disable
  31. @account.user.disable!
  32. redirect_to admin_account_path(@account.id)
  33. end
  34. def redownload
  35. @account.reset_avatar!
  36. @account.reset_header!
  37. @account.save!
  38. redirect_to admin_account_path(@account.id)
  39. end
  40. private
  41. def set_account
  42. @account = Account.find(params[:id])
  43. end
  44. def require_remote_account!
  45. redirect_to admin_account_path(@account.id) if @account.local?
  46. end
  47. def require_local_account!
  48. redirect_to admin_account_path(@account.id) unless @account.local? && @account.user.present?
  49. end
  50. def filtered_accounts
  51. AccountFilter.new(filter_params).results
  52. end
  53. def filter_params
  54. params.permit(
  55. :local,
  56. :remote,
  57. :by_domain,
  58. :silenced,
  59. :recent,
  60. :suspended,
  61. :username,
  62. :display_name,
  63. :email,
  64. :ip
  65. )
  66. end
  67. end
  68. end