Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WHISTLE-940: preform the default call repsonse on failure

  • Loading branch information...
commit 368c38ebc60eac2a7efa9cf51debc1af2fa0660b 1 parent 3bb687a
@k-anderson k-anderson authored
View
2  whistle_apps/apps/callflow/src/cf_call_command.erl
@@ -128,7 +128,7 @@ response(Code, Cause, Call) ->
response(Code, Cause, Media, Call) ->
CallId = cf_exe:callid(Call),
CtrlQ = cf_exe:control_queue_name(Call),
- wh_util:call_response(CallId, CtrlQ, Code, Cause, Media).
+ wh_call_response:send(CallId, CtrlQ, Code, Cause, Media).
%%--------------------------------------------------------------------
%% @public
View
23 whistle_apps/apps/callflow/src/cf_util.erl
@@ -10,6 +10,7 @@
-export([call_to_proplist/1]).
-export([lookup_callflow/1, lookup_callflow/2]).
-export([handle_bridge_failure/2, handle_bridge_failure/3]).
+-export([send_default_response/2]).
-export([get_sip_realm/2, get_sip_realm/3]).
-define(PROMPTS_CONFIG_CAT, <<(?CF_CONFIG_CAT)/binary, ".prompts">>).
@@ -368,6 +369,28 @@ handle_bridge_failure(Cause, Code, Call) ->
not_found
end.
+%%--------------------------------------------------------------------
+%% @public
+%% @doc
+%% Send and wait for a call failure cause response
+%% @end
+%%--------------------------------------------------------------------
+-spec send_default_response/2 :: (ne_binary(), #cf_call{}) -> ok.
+send_default_response(Cause, Call) ->
+ CallId = cf_exe:callid(Call),
+ CtrlQ = cf_exe:control_queue_name(Call),
+ case wh_call_response:send_default(CallId, CtrlQ, Cause) of
+ {error, no_response} -> ok;
+ {ok, NoopId} -> cf_call_command:wait_for_noop(NoopId)
+ end,
+ ok.
+
+%%--------------------------------------------------------------------
+%% @public
+%% @doc
+%% Get the sip realm
+%% @end
+%%--------------------------------------------------------------------
-spec get_sip_realm/2 :: (wh_json:json_object(), ne_binary()) -> 'undefined' | ne_binary().
-spec get_sip_realm/3 :: (wh_json:json_object(), ne_binary(), Default) -> Default | ne_binary().
View
15 whistle_apps/apps/callflow/src/module/cf_offnet.erl
@@ -44,11 +44,15 @@ handle(Data, #cf_call{account_id=AccountId, from_realm=AccountRealm, request_use
{<<"SUCCESS">>, _} ->
?LOG("completed successful offnet request"),
cf_exe:stop(Call);
- {<<"ERROR">>, Msg} ->
- ?LOG("offnet request error: ~p", [Msg]),
- cf_exe:continue(Call);
{Cause, Code} ->
- cf_util:handle_bridge_failure(Cause, Code, Call)
+ ?LOG("offnet request error, attempting to find failure branch for ~s:~s", [Code, Cause]),
+ case (cf_util:handle_bridge_failure(Cause, Call) =:= ok)
+ orelse (cf_util:handle_bridge_failure(Code, Call) =:= ok) of
+ true -> ok;
+ false ->
+ cf_util:send_default_response(Cause, Call),
+ cf_exe:continue(Call)
+ end
end.
%%--------------------------------------------------------------------
@@ -64,8 +68,7 @@ wait_for_offnet() ->
case wh_util:get_event_type(JObj) of
{ <<"resource">>, <<"offnet_resp">> } ->
{wh_json:get_value(<<"Response-Message">>, JObj)
- ,wh_json:get_value(<<"Error-Message">>, JObj
- ,wh_json:get_value(<<"Response-Code">>, JObj))};
+ ,wh_json:get_value(<<"Response-Code">>, JObj)};
_ ->
wait_for_offnet()
end;
View
15 whistle_apps/apps/callflow/src/module/cf_resources.erl
@@ -57,10 +57,10 @@ bridge_to_resources([{DestNum, Rsc, _CIDType}|T], Timeout, IgnoreEarlyMedia, Rin
]}]),
case (cf_util:handle_bridge_failure(Cause, Call) =:= ok)
orelse (cf_util:handle_bridge_failure(Code, Call) =:= ok) of
- true ->
- ok;
- false ->
- bridge_to_resources(T, Timeout, IgnoreEarlyMedia, Ringback, Call)
+ true -> ok;
+ false ->
+ cf_util:send_default_response(Cause, Call),
+ cf_exe:continue(Call)
end;
{fail, _} ->
bridge_to_resources(T, Timeout, IgnoreEarlyMedia, Ringback, Call);
@@ -72,7 +72,12 @@ bridge_to_resources([{DestNum, Rsc, _CIDType}|T], Timeout, IgnoreEarlyMedia, Rin
end;
bridge_to_resources([], _, _, _, Call) ->
?LOG("resources exhausted without success"),
- cf_exe:continue(Call).
+ case cf_util:handle_bridge_failure(<<"NO_ROUTE_DESTINATION">>, Call) =:= ok of
+ true -> ok;
+ false ->
+ cf_util:send_default_response(<<"NO_ROUTE_DESTINATION">>, Call),
+ cf_exe:continue(Call)
+ end.
%%--------------------------------------------------------------------
%% @private
Please sign in to comment.
Something went wrong with that request. Please try again.