Skip to content

Commit

Permalink
[4.3] Misc sync-up changes to acdc (2600hz#6575)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfinke authored and jamesaimonetti committed Jun 9, 2020
1 parent 4dc25e7 commit a028dd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 0 additions & 2 deletions applications/acdc/src/acdc_agent_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1427,13 +1427,11 @@ handle_event('load_endpoints', StateName, #state{agent_listener='undefined'}=Sta
gen_statem:cast(self(), 'load_endpoints'),
{'next_state', StateName, State};
handle_event('load_endpoints', StateName, #state{agent_id=AgentId
,agent_listener=AgentListener
,account_id=AccountId
,account_db=AccountDb
}=State) ->
Setters = [{fun kapps_call:set_account_id/2, AccountId}
,{fun kapps_call:set_account_db/2, AccountDb}
,{fun kapps_call:set_owner_id/2, AgentId}
,{fun kapps_call:set_resource_type/2, ?RESOURCE_TYPE_AUDIO}
],

Expand Down
16 changes: 7 additions & 9 deletions applications/acdc/src/acdc_agent_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ handle_cast({'bridge_to_member', Call, WinJObj, EPs, CDRUrl, RecordingUrl}, #sta
,kz_json:is_true(<<"Record-Caller">>, WinJObj, 'false')
),

acdc_util:bind_to_call_events(Call),

AgentCallIds = lists:append(maybe_connect_to_agent(MyQ, EPs, Call, RingTimeout, AgentId, CDRUrl)
,ACallIds),

Expand All @@ -592,8 +590,9 @@ handle_cast({'bridge_to_member', Call, WinJObj, EPs, CDRUrl, RecordingUrl}, #sta
,record_calls=ShouldRecord
,msg_queue_id=kz_json:get_value(<<"Server-ID">>, WinJObj)
,agent_call_ids=AgentCallIds
,cdr_urls=dict:store(kapps_call:call_id(Call), CDRUrl,
dict:store(AgentCallIds, CDRUrl, Urls)
,cdr_urls=dict:store(kapps_call:call_id(Call)
,CDRUrl
,dict:store(AgentCallIds, CDRUrl, Urls)
)
,recording_url=RecordingUrl
}
Expand Down Expand Up @@ -621,8 +620,9 @@ handle_cast({'bridge_to_member', Call, WinJObj, _, CDRUrl, RecordingUrl}, #state
,acdc_queue_id=kz_json:get_value(<<"Queue-ID">>, WinJObj)
,msg_queue_id=kz_json:get_value(<<"Server-ID">>, WinJObj)
,agent_call_ids=[AgentCallId | ACallIds]
,cdr_urls=dict:store(kapps_call:call_id(Call), CDRUrl,
dict:store(AgentCallId, CDRUrl, Urls)
,cdr_urls=dict:store(kapps_call:call_id(Call)
,CDRUrl
,dict:store(AgentCallId, CDRUrl, Urls)
)
,record_calls=ShouldRecord
,recording_url=RecordingUrl
Expand Down Expand Up @@ -716,8 +716,6 @@ handle_cast({'hangup_call'}, #state{my_id=MyId
handle_cast({'monitor_call', Call, WinJObj, RecordingUrl}, State) ->
_ = kapps_call:put_callid(Call),

acdc_util:bind_to_call_events(Call),

lager:debug("monitoring member call ~s", [kapps_call:call_id(Call)]),

{'noreply', State#state{call=Call
Expand Down Expand Up @@ -1032,7 +1030,7 @@ call_id(Call) ->
end.

-spec maybe_connect_to_agent(kz_term:ne_binary(), kz_json:objects(), kapps_call:call(), kz_term:api_integer(), kz_term:ne_binary(), kz_term:api_binary()) ->
kz_term:ne_binaries().
kz_term:proplist().
maybe_connect_to_agent(MyQ, EPs, Call, Timeout, AgentId, _CdrUrl) ->
MCallId = kapps_call:call_id(Call),
kz_util:put_callid(MCallId),
Expand Down
4 changes: 2 additions & 2 deletions applications/acdc/src/acdc_agents_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ new_thief(Call, QueueId) ->
AccountId = kapps_call:account_id(Call),
CallId = kapps_call:call_id(Call),
Id = ?THIEF_ID(AccountId, QueueId, CallId),
supervisor:start_child(?MODULE, ?CHILD(Id, [Call, QueueId])).
supervisor:start_child(?SERVER, ?CHILD(Id, [Call, QueueId])).

-spec stop_agent(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:sup_deletechild_ret().
stop_agent(AcctId, AgentId) ->
Expand Down Expand Up @@ -180,7 +180,7 @@ start_agent(AcctId, AgentId, AgentJObj) ->
-spec start_agent(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), [any()]) -> kz_types:sup_startchild_ret().
start_agent(AcctId, AgentId, AgentJObj, ExtraArgs) ->
Id = ?CHILD_ID(AcctId, AgentId),
case supervisor:start_child(?MODULE, ?CHILD(Id, [AcctId, AgentId, AgentJObj] ++ ExtraArgs)) of
case supervisor:start_child(?SERVER, ?CHILD(Id, [AcctId, AgentId, AgentJObj] ++ ExtraArgs)) of
{'error', 'already_present'}=E ->
lager:debug("agent ~s(~s) already present", [AgentId, AcctId]),
E;
Expand Down

0 comments on commit a028dd8

Please sign in to comment.