forked from 2600hz/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HELP-10237: refactor decision-making for call recording (2600hz#6024)
* HELP-10237: improve communication about call recording settings 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
2a4adc1
commit 6d2bebe
Showing
11 changed files
with
530 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
%%%----------------------------------------------------------------------------- | ||
%%% @copyright (C) 2011-2019, 2600Hz | ||
%%% @doc | ||
%%% This Source Code Form is subject to the terms of the Mozilla Public | ||
%%% License, v. 2.0. If a copy of the MPL was not distributed with this | ||
%%% file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
%%% | ||
%%% @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.