Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acdc fix pickup and exit by dtmf #6745

Open
wants to merge 3 commits into
base: 4.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions applications/acdc/src/acdc_agent_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ call_event(ServerRef, <<"error">>, <<"dialplan">>, JObj) ->
gen_statem:cast(ServerRef, {'dialplan_error', kz_json:get_value(<<"Application-Name">>, Req)});
call_event(ServerRef, <<"call_event">>, <<"CHANNEL_REPLACED">>, JObj) ->
gen_statem:cast(ServerRef, {'channel_replaced', JObj});
call_event(ServerRef, <<"call_event">>, <<"CHANNEL_INTERCEPTED">>, JObj) ->
gen_statem:cast(ServerRef, {'channel_intercepted', JObj});
call_event(ServerRef, <<"call_event">>, <<"CHANNEL_TRANSFEREE">>, JObj) ->
Transferor = kz_call_event:other_leg_call_id(JObj),
Transferee = kz_call_event:call_id(JObj),
Expand Down Expand Up @@ -896,6 +898,30 @@ ringing('cast', {'leg_destroyed', _CallId}, State) ->
{'next_state', 'ringing', State};
ringing('cast', {'usurp_control', _CallId}, State) ->
{'next_state', 'ringing', State};

ringing('cast', {'channel_intercepted', JObj}, #state{agent_listener=AgentListener
,account_id=AccountId
,agent_id=AgentId
,member_call_id=CallId
,queue_notifications=Ns
,member_call_queue_id=QueueId
}=State) ->
ACallId = kz_json:get_value(<<"Other-Leg-Call-ID">>, JObj),
lager:debug("channel_intercepted: ~s", [ACallId]),

acdc_agent_listener:hangup_call(AgentListener),
acdc_util:unbind_from_call_events(ACallId),
lager:debug("stopping ringing agent in order to intercept"),
acdc_stats:call_missed(AccountId, QueueId, AgentId, CallId, <<"call intercepted">>),

acdc_agent_listener:presence_update(AgentListener, ?PRESENCE_GREEN),

apply_state_updates(clear_call(State, 'ready')),

maybe_notify(Ns, ?NOTIFY_PICKUP, State),

{'next_state', 'wrapup', State#state{wrapup_ref=hangup_call(State, 'agent')}};

ringing('cast', Evt, State) ->
handle_event(Evt, 'ringing', State);
ringing({'call', From}, 'status', #state{member_call_id=MemberCallId
Expand Down
2 changes: 2 additions & 0 deletions applications/acdc/src/acdc_agent_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ maybe_connect_to_agent(MyQ, EPs, Call, Timeout, AgentId, _CdrUrl) ->
,{<<"Retain-CID">>, <<"true">>}
,{<<"Agent-ID">>, AgentId}
,{<<"Member-Call-ID">>, MCallId}
,{<<"Originate-Signal-Bond">>, MCallId}
,{<<"Original-Caller-ID-Name">>, OriginalCIDName}
,{<<"Original-Caller-ID-Number">>, OriginalCIDNumber}
]),
Expand All @@ -1058,6 +1059,7 @@ maybe_connect_to_agent(MyQ, EPs, Call, Timeout, AgentId, _CdrUrl) ->
,<<"Retain-CID">>
,<<"Authorizing-ID">>
,<<"Authorizing-Type">>
,<<"Originate-Signal-Bond">>
]}
,{<<"Account-ID">>, AcctId}
,{<<"Resource-Type">>, <<"originate">>}
Expand Down
24 changes: 23 additions & 1 deletion applications/acdc/src/acdc_queue_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ ready({'call', From}, Event, State) ->
handle_sync_event(Event, From, ready, State);

ready('info', {'timeout', _, ?COLLECT_RESP_MESSAGE}, State) ->
{'next_state', 'ready', State}.
{'next_state', 'ready', State};

ready('info', Event, State) ->
handle_event(Event, ready, State).

%%------------------------------------------------------------------------------
%% @doc
Expand Down Expand Up @@ -330,6 +333,10 @@ connect_req('cast', {'accepted', AcceptJObj}=Accept, #state{member_call=Call}=St
lager:debug("received (and ignoring) acceptance payload"),
{'next_state', 'connect_req', State}
end;

connect_req('cast', {'channel_bridged', _BridgeJObj}=Accept, State) ->
connecting('cast', Accept, State);

connect_req('cast', {'retry', _RetryJObj}, State) ->
lager:debug("recv retry response before win sent"),
{'next_state', 'connect_req', State};
Expand Down Expand Up @@ -447,6 +454,21 @@ connecting('cast', {'accepted', AcceptJObj}, #state{listener_proc=ListenerSrv
{'next_state', 'connecting', State}
end;

connecting('cast', {'channel_bridged', _BridgeJObj}, #state{listener_proc=ListenerSrv
,member_call=Call
,agent_ring_timer_ref=AgentRef
,collect_ref=CollectRef
}=State) ->
lager:debug("recv channel_bridged from agent"),
CallId = kapps_call:call_id(Call),
webseq:evt(?WSD_ID, self(), CallId, <<"member call - agent acceptance">>),

maybe_stop_timer(CollectRef),
maybe_stop_timer(AgentRef),

acdc_queue_listener:finish_member_call(ListenerSrv),
{'next_state', 'ready', clear_member_call(State), 'hibernate'};

connecting('cast', {'retry', RetryJObj}, #state{agent_ring_timer_ref=AgentRef
,collect_ref=CollectRef
,member_call_winner=Winner
Expand Down
2 changes: 1 addition & 1 deletion applications/acdc/src/acdc_queue_manager.erl
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ sort_agent(A, B) ->
%% Otherwise CRs will never be empty
-spec remove_unknown_agents(pid(), kz_json:objects()) -> kz_json:objects().
remove_unknown_agents(Mgr, CRs) ->
case gen_listener:call(Mgr, 'current_agents') of
case gen_listener:call(Mgr, 'agents') of
[] -> [];
Agents ->
[CR || CR <- CRs,
Expand Down
1 change: 1 addition & 0 deletions applications/ecallmgr/src/ecallmgr.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
,{<<"sip_rh_X-Redirect-Server">>, <<"sip_rh_X-Redirect-Server">>}
,{<<"tts_engine">>, <<"tts_engine">>}
,{<<"tts_voice">>, <<"tts_voice">>}
,{<<"Originate-Signal-Bond">>, <<"originate_signal_bond">>}
]).

%% [{FreeSWITCH-App-Name, Kazoo-App-Name}] Dialplan-related
Expand Down