account_actions_controller.rb 793 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # frozen_string_literal: true
  2. class Api::V1::Admin::AccountActionsController < Api::BaseController
  3. include Authorization
  4. before_action -> { authorize_if_got_token! :'admin:write', :'admin:write:accounts' }
  5. before_action :set_account
  6. after_action :verify_authorized
  7. def create
  8. authorize @account, :show?
  9. account_action = Admin::AccountAction.new(resource_params)
  10. account_action.target_account = @account
  11. account_action.current_account = current_account
  12. account_action.save!
  13. render_empty
  14. end
  15. private
  16. def set_account
  17. @account = Account.find(params[:account_id])
  18. end
  19. def resource_params
  20. params.permit(
  21. :type,
  22. :report_id,
  23. :warning_preset_id,
  24. :text,
  25. :send_email_notification
  26. )
  27. end
  28. end