# frozen_string_literal: true
module Admin
class RelaysController < BaseController
before_action :set_relay, except: [:index, :new, :create]
before_action :require_signatures_enabled!, only: [:new, :create, :enable]
def index
authorize :relay, :update?
@relays = Relay.all
end
def new
@relay = Relay.new
def create
@relay = Relay.new(resource_params)
if @relay.save
@relay.enable!
redirect_to admin_relays_path
else
render action: :new
def destroy
@relay.destroy
def enable
def disable
@relay.disable!
private
def set_relay
@relay = Relay.find(params[:id])
def resource_params
params.require(:relay).permit(:inbox_url)
def require_signatures_enabled!
redirect_to admin_relays_path, alert: I18n.t('admin.relays.signatures_not_enabled') if authorized_fetch_mode?