From a0ad7b02c6a395e7872ffb7e127743bad2b52c92 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Tue, 13 Jul 2021 11:02:10 -0700 Subject: [PATCH 1/2] Skip adding preflow on transfers When transferring a call, don't prepend a preflow. Previously, preflows were prepended to all callflows when present. If a preflow defined a TTS like "Welcome to Company X", the caller would hear the TTS on call connection and, if transferred to a parking slot via *31 (for instance), would hear the preflow TTS again before hearing hold music. Backport of https://github.com/2600hz/kazoo-callflow/pull/77 --- applications/callflow/src/cf_route_req.erl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/applications/callflow/src/cf_route_req.erl b/applications/callflow/src/cf_route_req.erl index cb548dd1f72..c89a83d279a 100644 --- a/applications/callflow/src/cf_route_req.erl +++ b/applications/callflow/src/cf_route_req.erl @@ -59,6 +59,17 @@ handle_req(RouteReq, Props) -> ,boolean() ) -> 'ok'. maybe_prepend_preflow(RouteReq, Props, Call, Callflow, NoMatch) -> + CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, RouteReq), + TransferVars = [<<"Referred-By">>, <<"Redirected-By">>], + IsTransfer = kz_json:get_first_defined(TransferVars, CCVs) =/= 'undefined', + + maybe_prepend_preflow(RouteReq, Props, Call, Callflow, NoMatch, IsTransfer). + + +maybe_prepend_preflow(RouteReq, Props, Call, Callflow, NoMatch, 'true') -> + lager:info("request is the result of a transfer, skipping preflow"), + maybe_reply_to_req(RouteReq, Props, Call, Callflow, NoMatch); +maybe_prepend_preflow(RouteReq, Props, Call, Callflow, NoMatch, 'false') -> AccountId = kapps_call:account_id(Call), case kzd_accounts:fetch(AccountId) of {'error', _E} -> @@ -177,7 +188,7 @@ send_route_response(Flow, RouteReq, Call) -> ,{<<"Custom-Channel-Vars">>, CCVs} ,{<<"Custom-Application-Vars">>, kapps_call:custom_application_vars(Call)} ,{<<"Context">>, kapps_call:context(Call)} - | kz_api:default_headers(?APP_NAME, ?APP_VERSION) + | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]), ServerId = kz_api:server_id(RouteReq), Publisher = fun(P) -> kapi_route:publish_resp(ServerId, P) end, From 7495c658e5218780ca5ddfc004dd336e15602279 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Tue, 13 Jul 2021 13:06:28 -0700 Subject: [PATCH 2/2] fmt --- applications/callflow/src/cf_route_req.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/callflow/src/cf_route_req.erl b/applications/callflow/src/cf_route_req.erl index c89a83d279a..ab86b53325b 100644 --- a/applications/callflow/src/cf_route_req.erl +++ b/applications/callflow/src/cf_route_req.erl @@ -188,7 +188,7 @@ send_route_response(Flow, RouteReq, Call) -> ,{<<"Custom-Channel-Vars">>, CCVs} ,{<<"Custom-Application-Vars">>, kapps_call:custom_application_vars(Call)} ,{<<"Context">>, kapps_call:context(Call)} - | kz_api:default_headers(?APP_NAME, ?APP_VERSION) + | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]), ServerId = kz_api:server_id(RouteReq), Publisher = fun(P) -> kapi_route:publish_resp(ServerId, P) end,