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

44 lines
1.0 KiB

  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, retroactive_unblock?)
  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. def retroactive_unblock?
  32. resource_params[:retroactive] == '1'
  33. end
  34. end
  35. end