Skip to content

Commit

Permalink
track cfwd to set authorizing-id (2600hz#5336)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazedo authored and k-anderson committed Dec 11, 2018
1 parent d81bd99 commit 74c6cc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions applications/callflow/src/module/cf_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ get_channel_vars(Call) ->
,fun maybe_require_ignore_early_media/2
,fun maybe_require_single_fail/2
,fun maybe_set_bridge_generate_comfort_noise/2
,fun maybe_call_forward/2
],
CCVs = lists:foldl(fun(F, Acc) -> F(Call, Acc) end
,[]
Expand All @@ -167,6 +168,17 @@ maybe_require_ignore_early_media(Call, Acc) ->
maybe_require_single_fail(Call, Acc) ->
[{<<"Require-Fail-On-Single-Reject">>, kapps_call:custom_channel_var(<<"Require-Fail-On-Single-Reject">>, Call)} | Acc].

-spec maybe_call_forward(kapps_call:call(), kz_term:proplist()) -> kz_term:proplist().
maybe_call_forward(Call, Acc) ->
case kapps_call:is_call_forward(Call) of
'true' -> [{<<"Authorizing-ID">>, kapps_call:authorizing_id(Call)}
,{<<"Authorizing-Type">>, kapps_call:authorizing_type(Call)}
,{<<"Application-Other-Leg-UUID">>, kapps_call:custom_channel_var(<<"Call-Forward-For-UUID">>, Call)}
| Acc
];
'false' -> Acc
end.

-spec get_bypass_e164(kz_json:object()) -> boolean().
get_bypass_e164(Data) ->
kz_json:is_true(<<"do_not_normalize">>, Data)
Expand Down
9 changes: 9 additions & 0 deletions core/kazoo_call/src/kapps_call.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
]).

-export([is_recording/1, set_is_recording/2]).
-export([is_call_forward/1]).

-ifdef(TEST).
-export([eq/2]).
Expand Down Expand Up @@ -207,6 +208,7 @@
,call_bridged = 'false' :: boolean() %% Specified during call termination whether the call had been bridged
,message_left = 'false' :: boolean() %% Specified during call termination whether the caller left a voicemail message
,is_recording = 'false' :: boolean() %% Control account level recording
,is_call_forward = 'false' :: boolean() %% is this call forward call
}).

-type call() :: #kapps_call{}.
Expand Down Expand Up @@ -319,6 +321,7 @@ from_route_req(RouteReq, #kapps_call{call_id=OldCallId
,to_tag = kz_json:get_ne_binary_value(<<"To-Tag">>, RouteReq, to_tag(Call))
,from_tag = kz_json:get_ne_binary_value(<<"From-Tag">>, RouteReq, from_tag(Call))
,direction = kz_json:get_ne_binary_value(<<"Call-Direction">>, RouteReq, direction(Call))
,is_call_forward = kz_json:is_true(<<"Call-Forward">>, CCVs, is_call_forward(Call))
}.

-spec from_route_win(kz_json:object()) -> call().
Expand Down Expand Up @@ -479,6 +482,7 @@ from_json(JObj, #kapps_call{ccvs=OldCCVs
,call_bridged = kz_json:is_true(<<"Call-Bridged">>, JObj, call_bridged(Call))
,message_left = kz_json:is_true(<<"Message-Left">>, JObj, message_left(Call))
,is_recording = kz_json:is_true(<<"Is-Recording">>, JObj, is_recording(Call))
,is_call_forward = kz_json:is_true(<<"Is-Call-Forward">>, JObj, is_call_forward(Call))
}.

%%------------------------------------------------------------------------------
Expand Down Expand Up @@ -530,6 +534,7 @@ to_proplist(#kapps_call{}=Call) ->
,{<<"From-User">>, from_user(Call)}
,{<<"Inception">>, inception(Call)}
,{<<"Is-Recording">>, is_recording(Call)}
,{<<"Is-Call-Forward">>, is_call_forward(Call)}
,{<<"Key-Value-Store">>, kvs_to_proplist(Call)}
,{<<"Language">>, language(Call)}
,{<<"Message-Left">>, message_left(Call)}
Expand Down Expand Up @@ -1589,6 +1594,10 @@ set_is_recording(IsRecording, #kapps_call{}=Call) ->
is_recording(#kapps_call{is_recording=IsRecording}) ->
IsRecording.

-spec is_call_forward(call()) -> boolean().
is_call_forward(#kapps_call{is_call_forward=IsCallForward}) ->
IsCallForward.

-ifdef(TEST).
eq(Call, Call1) ->
eq(tuple_to_list(Call), tuple_to_list(Call1), 1).
Expand Down
7 changes: 6 additions & 1 deletion core/kazoo_endpoint/src/kz_endpoint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,11 @@ maybe_set_call_forward({Endpoint, Call, CallFwd, CCVs}) ->
{Endpoint, Call, CallFwd
,kz_json:set_values([{<<"Call-Forward">>, <<"true">>}
,{<<"Authorizing-Type">>, <<"device">>}
,{<<"Authorizing-ID">>, kz_doc:id(Endpoint)}
,{<<"Call-Forward-From">>, kapps_call:inception_type(Call)}
,{<<"Call-Forward-For-UUID">>, kapps_call:other_leg_call_id(Call)}
,{<<"Require-Ignore-Early-Media">>, <<"true">>}
,{<<"Ignore-Early-Media">>, <<"true">>}
| bowout_settings('undefined' =:= kapps_call:call_id_direct(Call))
]
,CCVs
Expand Down Expand Up @@ -1669,7 +1674,7 @@ maybe_set_confirm_properties({Endpoint, Call, CallFwd, CCVs}=Acc) ->
,{<<"Confirm-Read-Timeout">>, kz_term:to_binary(7 * ?MILLISECONDS_IN_SECOND)}
,{<<"Confirm-File">>, ?CONFIRM_FILE(Call)}
,{<<"Require-Ignore-Early-Media">>, <<"true">>}
,{<<"Require-Fail-On-Single-Reject">>, <<"USER_BUSY,CALL_REJECTED,NO_ANSWER,NORMAL_CLEARING">>}
,{<<"Require-Fail-On-Single-Reject">>, <<"USER_BUSY,CALL_REJECTED,NO_ANSWER,NORMAL_CLEARING,PROGRESS_TIMEOUT">>}
],
{Endpoint, Call, CallFwd
,kz_json:merge_jobjs(kz_json:from_list(Confirm), CCVs)
Expand Down

0 comments on commit 74c6cc8

Please sign in to comment.