闭社主体 forked from https://github.com/tootsuite/mastodon
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.

61 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class AccountsController < BaseController
  4. before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload]
  5. before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
  6. def index
  7. @accounts = filtered_accounts.page(params[:page])
  8. end
  9. def show; end
  10. def subscribe
  11. Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
  12. redirect_to admin_account_path(@account.id)
  13. end
  14. def unsubscribe
  15. Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
  16. redirect_to admin_account_path(@account.id)
  17. end
  18. def redownload
  19. @account.reset_avatar!
  20. @account.reset_header!
  21. @account.save!
  22. redirect_to admin_account_path(@account.id)
  23. end
  24. private
  25. def set_account
  26. @account = Account.find(params[:id])
  27. end
  28. def require_remote_account!
  29. redirect_to admin_account_path(@account.id) if @account.local?
  30. end
  31. def filtered_accounts
  32. AccountFilter.new(filter_params).results
  33. end
  34. def filter_params
  35. params.permit(
  36. :local,
  37. :remote,
  38. :by_domain,
  39. :silenced,
  40. :recent,
  41. :suspended,
  42. :username,
  43. :display_name,
  44. :email,
  45. :ip
  46. )
  47. end
  48. end
  49. end