diff --git a/app/controllers/repp/v1/domains/contacts_controller.rb b/app/controllers/repp/v1/domains/contacts_controller.rb index c41862b39..2f8b7c1b4 100644 --- a/app/controllers/repp/v1/domains/contacts_controller.rb +++ b/app/controllers/repp/v1/domains/contacts_controller.rb @@ -41,7 +41,9 @@ module Repp contact_create_params[:contacts].each { |c| c[:action] = action } action = Actions::DomainUpdate.new(@domain, contact_create_params, current_user) + # rubocop:disable Style/AndOr handle_errors(@domain) and return unless action.call + # rubocop:enable Style/AndOr render_success(data: { domain: { name: @domain.name } }) end diff --git a/app/controllers/repp/v1/domains/dnssec_controller.rb b/app/controllers/repp/v1/domains/dnssec_controller.rb index ec3a3bd7f..0c30fd84f 100644 --- a/app/controllers/repp/v1/domains/dnssec_controller.rb +++ b/app/controllers/repp/v1/domains/dnssec_controller.rb @@ -25,15 +25,7 @@ module Repp param_group :dns_keys_apidoc, DnssecController end def create - dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'add' } - action = Actions::DomainUpdate.new(@domain, dnssec_params[:dnssec], current_user) - - unless action.call - handle_errors(@domain) - return - end - - render_success(data: { domain: { name: @domain.name } }) + cta('add') end api :DELETE, 'repp/v1/domains/:domain_name/dnssec' @@ -41,13 +33,16 @@ module Repp param_group :dns_keys_apidoc, DnssecController end def destroy - dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = 'rem' } + cta('rem') + end + + def cta(action = 'add') + dnssec_params[:dnssec][:dns_keys].each { |n| n[:action] = action } action = Actions::DomainUpdate.new(@domain, dnssec_params[:dnssec], current_user) - unless action.call - handle_errors(@domain) - return - end + # rubocop:disable Style/AndOr + (handle_errors(@domain) and return) unless action.call + # rubocop:enable Style/AndOr render_success(data: { domain: { name: @domain.name } }) end