闭社主体 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.

40 lines
1001 B

  1. # frozen_string_literal: true
  2. module Admin
  3. class DomainBlocksController < BaseController
  4. def index
  5. @blocks = DomainBlock.page(params[:page])
  6. end
  7. def new
  8. @domain_block = DomainBlock.new
  9. end
  10. def create
  11. @domain_block = DomainBlock.new(resource_params)
  12. if @domain_block.save
  13. DomainBlockWorker.perform_async(@domain_block.id)
  14. redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg')
  15. else
  16. render :new
  17. end
  18. end
  19. def show
  20. @domain_block = DomainBlock.find(params[:id])
  21. end
  22. def destroy
  23. @domain_block = DomainBlock.find(params[:id])
  24. UnblockDomainService.new.call(@domain_block, resource_params[:retroactive])
  25. redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.destroyed_msg')
  26. end
  27. private
  28. def resource_params
  29. params.require(:domain_block).permit(:domain, :severity, :reject_media, :retroactive)
  30. end
  31. end
  32. end