-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.3] HELP-10237: refactor decision-making for call recording (#6026)
* [4.3] HELP-10237: refactor decision-making for call recording Added tests for kz_endpoint when merging call recording settings to clarify the behaviour. Updated documentation to clarify precedence and the duality of account and endpoint call recording settings.
- Loading branch information
1 parent
2d2fd6d
commit 0d61ae9
Showing
12 changed files
with
531 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
%%%----------------------------------------------------------------------------- | ||
%%% @copyright (C) 2011-2019, 2600Hz | ||
%%% @doc | ||
%%% @end | ||
%%%----------------------------------------------------------------------------- | ||
-module(kz_account_recording). | ||
|
||
-export([maybe_record_inbound/3 | ||
,maybe_record_outbound/3 | ||
]). | ||
|
||
-include("kazoo_endpoint.hrl"). | ||
|
||
-define(ACCOUNT_INBOUND_RECORDING(Network), [<<"call_recording">>, <<"account">>, <<"inbound">>, Network]). | ||
-define(ACCOUNT_OUTBOUND_RECORDING(Network), [<<"call_recording">>, <<"account">>, <<"outbound">>, Network]). | ||
|
||
-define(ACCOUNT_INBOUND_RECORDING_LABEL(Network), <<"inbound from ", Network/binary, " to account">>). | ||
-define(ACCOUNT_OUTBOUND_RECORDING_LABEL(Network), <<"outbound to ", Network/binary, " from account">>). | ||
|
||
%% @doc should recording be started on call TO the endpoint | ||
-spec maybe_record_inbound(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> | ||
{'true', kapps_call:call()} | 'false'. | ||
maybe_record_inbound(FromNetwork, Endpoint, Call) -> | ||
maybe_record_inbound(FromNetwork, Endpoint, Call, kz_json:get_json_value(?ACCOUNT_INBOUND_RECORDING(FromNetwork), Endpoint)). | ||
|
||
-spec maybe_record_inbound(kz_term:ne_binary(), kz_json:object(), kapps_call:call(), kz_term:api_object()) -> | ||
{'true', kapps_call:call()} | 'false'. | ||
maybe_record_inbound(_FromNetwork, _Endpoint, _Call, 'undefined') -> 'false'; | ||
maybe_record_inbound(FromNetwork, _Endpoint, Call, Data) -> | ||
case kz_json:is_true(<<"enabled">>, Data) of | ||
'false' -> 'false'; | ||
'true' -> | ||
LabeledData = kz_json:set_value(<<"origin">>, ?ACCOUNT_INBOUND_RECORDING_LABEL(FromNetwork), Data), | ||
{'true' | ||
,kapps_call:start_recording(LabeledData, kapps_call:kvs_store('recording_follow_transfer', 'false', Call)) | ||
} | ||
end. | ||
|
||
%% @doc maybe start recording on call made FROM the endpoint | ||
-spec maybe_record_outbound(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> | ||
{'true', kapps_call:call()} | 'false'. | ||
maybe_record_outbound(ToNetwork, Endpoint, Call) -> | ||
maybe_record_outbound(ToNetwork, Endpoint, Call, kz_json:get_json_value(?ACCOUNT_OUTBOUND_RECORDING(ToNetwork), Endpoint)). | ||
|
||
-spec maybe_record_outbound(kz_term:ne_binary(), kz_json:object(), kapps_call:call(), kz_term:api_object()) -> | ||
{'true', kapps_call:call()} | 'false'. | ||
maybe_record_outbound(_ToNetwork, _Endpoint, _Call, 'undefined') -> 'false'; | ||
maybe_record_outbound(ToNetwork, _Endpoint, Call, Data) -> | ||
case kz_json:is_true(<<"enabled">>, Data) of | ||
'false' -> 'false'; | ||
'true' -> | ||
LabeledData = kz_json:set_value(<<"origin">>, ?ACCOUNT_OUTBOUND_RECORDING_LABEL(ToNetwork), Data), | ||
{'true' | ||
,kapps_call:start_recording(LabeledData, kapps_call:kvs_store('recording_follow_transfer', 'false', Call)) | ||
} | ||
end. |
Oops, something went wrong.