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

  1. # frozen_string_literal: true
  2. class Admin::DomainAllowsController < Admin::BaseController
  3. before_action :set_domain_allow, only: [:destroy]
  4. def new
  5. authorize :domain_allow, :create?
  6. @domain_allow = DomainAllow.new(domain: params[:_domain])
  7. end
  8. def create
  9. authorize :domain_allow, :create?
  10. @domain_allow = DomainAllow.new(resource_params)
  11. if @domain_allow.save
  12. log_action :create, @domain_allow
  13. redirect_to admin_instances_path, notice: I18n.t('admin.domain_allows.created_msg')
  14. else
  15. render :new
  16. end
  17. end
  18. def destroy
  19. authorize @domain_allow, :destroy?
  20. UnallowDomainService.new.call(@domain_allow)
  21. redirect_to admin_instances_path, notice: I18n.t('admin.domain_allows.destroyed_msg')
  22. end
  23. private
  24. def set_domain_allow
  25. @domain_allow = DomainAllow.find(params[:id])
  26. end
  27. def resource_params
  28. params.require(:domain_allow).permit(:domain)
  29. end
  30. end