diff --git a/app/controllers/api/v1/inbox_members_controller.rb b/app/controllers/api/v1/inbox_members_controller.rb index 6078b1181..93476de88 100644 --- a/app/controllers/api/v1/inbox_members_controller.rb +++ b/app/controllers/api/v1/inbox_members_controller.rb @@ -10,12 +10,8 @@ class Api::V1::InboxMembersController < Api::BaseController # the new ones are the agents which are to be added to the inbox if @inbox begin - agents_to_be_added_ids.each do |user_id| - @inbox.add_member(user_id) - end - agents_to_be_removed_ids.each do |user_id| - @inbox.remove_member(user) - end + add_agents + remove_agents head :ok rescue => e render_could_not_create_error("Could not add agents to inbox") @@ -31,6 +27,18 @@ class Api::V1::InboxMembersController < Api::BaseController private + def add_agents + agents_to_be_added_ids.each do |user_id| + @inbox.add_member(user_id) + end + end + + def remove_agents + agents_to_be_removed_ids.each do |user_id| + @inbox.remove_member(user) + end + end + def agents_to_be_added_ids params[:user_ids] - @current_agents_ids end