From 469823d7319aa78e4576d93d7247d917457d8927 Mon Sep 17 00:00:00 2001 From: Roman Galeev Date: Mon, 16 Jan 2017 14:58:26 +0100 Subject: [PATCH] KAZOO-5118: forcefully set caller-id on transfered calls if specified (#3091) * KAZOO-5118: forcefully set caller-id on transfered calls if specified * make fmt * use set instead of export --- applications/crossbar/src/modules/cb_modules_util.erl | 9 ++++++++- applications/ecallmgr/src/ecallmgr_originate.erl | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/applications/crossbar/src/modules/cb_modules_util.erl b/applications/crossbar/src/modules/cb_modules_util.erl index ebdad5fa92b..0897e36554f 100644 --- a/applications/crossbar/src/modules/cb_modules_util.erl +++ b/applications/crossbar/src/modules/cb_modules_util.erl @@ -363,7 +363,14 @@ originate_quickcall(Endpoints, Call, Context) -> ,{<<"Dial-Endpoint-Method">>, <<"simultaneous">>} ,{<<"Continue-On-Fail">>, 'false'} ,{<<"Custom-Channel-Vars">>, kz_json:from_list(CCVs)} - ,{<<"Export-Custom-Channel-Vars">>, [<<"Account-ID">>, <<"Retain-CID">>, <<"Authorizing-ID">>, <<"Authorizing-Type">>]} + ,{<<"Export-Custom-Channel-Vars">>, [ + <<"Account-ID">> + , <<"Retain-CID">> + , <<"Authorizing-ID">> + , <<"Authorizing-Type">> + , <<"Outbound-Callee-ID-Number">> + , <<"Outbound-Callee-ID-Name">> + ]} | kz_api:default_headers(<<"resource">>, <<"originate_req">>, ?APP_NAME, ?APP_VERSION) ]), kz_amqp_worker:cast(Request, fun kapi_resource:publish_originate_req/1), diff --git a/applications/ecallmgr/src/ecallmgr_originate.erl b/applications/ecallmgr/src/ecallmgr_originate.erl index 62a9423922b..029146e4346 100644 --- a/applications/ecallmgr/src/ecallmgr_originate.erl +++ b/applications/ecallmgr/src/ecallmgr_originate.erl @@ -662,6 +662,7 @@ get_unset_vars(JObj) -> ,maybe_fix_ignore_early_media(Export) ,maybe_fix_group_confirm(Export) ,maybe_fix_fs_auto_answer_bug(Export) + ,maybe_fix_caller_id(Export, JObj) ,"^" ] end. @@ -688,6 +689,14 @@ maybe_fix_fs_auto_answer_bug(Export) -> "^unset:sip_h_Call-Info^unset:sip_h_Alert-Info^unset:alert_info^unset:sip_invite_params^set:sip_auto_answer=false" end. +-spec maybe_fix_caller_id(strings(), kz_json:object()) -> string(). +maybe_fix_caller_id(Export, JObj) -> + Fix = [ + {lists:member("origination_callee_id_name", Export), kz_json:get_value(<<"Outbound-Callee-ID-Name">>, JObj), "effective_caller_id_name"} + ,{lists:member("origination_callee_id_number", Export), kz_json:get_value(<<"Outbound-Callee-ID-Number">>, JObj), "effective_caller_id_number"} + ], + string:join([ "^set:" ++ Key ++ "=" ++ erlang:binary_to_list(Value) || {IsTrue, Value, Key} <- Fix, IsTrue ], ":"). + -spec publish_error(ne_binary(), created_uuid() | api_binary(), kz_json:object(), api_binary()) -> 'ok'. publish_error(_, _, _, 'undefined') -> 'ok'; publish_error(Error, {_, UUID}, Request, ServerId) ->