Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PISTON-1290 added the ability to be able to skip call recording for feature calls #6723

Open
wants to merge 2 commits into
base: 4.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions applications/crossbar/doc/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
1 change: 1 addition & 0 deletions applications/crossbar/doc/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
1 change: 1 addition & 0 deletions applications/crossbar/doc/ref/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
1 change: 1 addition & 0 deletions applications/crossbar/doc/ref/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
1 change: 1 addition & 0 deletions applications/crossbar/doc/ref/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
1 change: 1 addition & 0 deletions applications/crossbar/doc/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`enabled` | is recording enabled | `boolean()` | | `false` |
`format` | What format to store the recording on disk | `string('mp3' | 'wav')` | | `false` |
`record_feature_code_calls` | Record calls to feature codes | `boolean()` | `true` | `false` |
`record_min_sec` | The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted | `integer()` | | `false` |
`record_on_answer` | Recording should start on answer | `boolean()` | | `false` |
`record_on_bridge` | Recording should start on bridge | `boolean()` | | `false` |
Expand Down
5 changes: 5 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,11 @@
],
"type": "string"
},
"record_feature_code_calls": {
"default": true,
"description": "Record calls to feature codes",
"type": "boolean"
},
"record_min_sec": {
"description": "The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted",
"type": "integer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
],
"type": "string"
},
"record_feature_code_calls": {
"default": true,
"description": "Record calls to feature codes",
"type": "boolean"
},
"record_min_sec": {
"description": "The minimum length, in seconds, the recording must be to be considered successful. Otherwise it is deleted",
"type": "integer"
Expand Down
22 changes: 22 additions & 0 deletions core/kazoo_call/src/kapps_call.erl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
,mask_recording/1, mask_recording/2
,unmask_recording/1, unmask_recording/2
,stop_recording/1
,should_skip_feature_calls_recording/2
]).

-export([is_recording/1, set_is_recording/2]).
Expand Down Expand Up @@ -1609,6 +1610,27 @@ get_recordings(Call) ->
Q -> Q
end.

%%------------------------------------------------------------------------------
%% @doc Check if we should record calls to feature codes.
%% First, we check if the callee number starts with * and then check
%% if the `record_feature_code_calls' param is set.
%% If the call is a feature call and record feature code calls is false,
%% then we skip the call recording.
%% @end
%%------------------------------------------------------------------------------
-spec should_skip_feature_calls_recording(call(), kz_term:api_object()) -> boolean().
should_skip_feature_calls_recording(Call, Data) ->
is_feature_call(request_user(Call))
andalso not should_record_feature_code_calls(Data).

-spec is_feature_call(kz_term:ne_binary()) -> boolean().
is_feature_call(<<"*", _/binary>>) -> 'true';
is_feature_call(_) -> 'false'.

-spec should_record_feature_code_calls(kz_term:api_object()) -> boolean().
should_record_feature_code_calls(Data) ->
kz_json:is_true(<<"record_feature_code_calls">>, Data, 'true').

-spec inception_type(call()) -> kz_term:ne_binary().
inception_type(#kapps_call{inception='undefined'}) -> <<"onnet">>;
inception_type(#kapps_call{}) -> <<"offnet">>.
Expand Down
6 changes: 4 additions & 2 deletions core/kazoo_endpoint/src/kz_account_recording.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ maybe_record_inbound(FromNetwork, Endpoint, Call) ->
{'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
case kz_json:is_true(<<"enabled">>, Data)
andalso not kapps_call:should_skip_feature_calls_recording(Call, Data) of
'false' -> 'false';
'true' ->
LabeledData = kz_json:set_value(<<"origin">>, ?ACCOUNT_INBOUND_RECORDING_LABEL(FromNetwork), Data),
Expand All @@ -46,7 +47,8 @@ maybe_record_outbound(ToNetwork, Endpoint, Call) ->
{'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
case kz_json:is_true(<<"enabled">>, Data)
andalso not kapps_call:should_skip_feature_calls_recording(Call, Data) of
'false' -> 'false';
'true' ->
LabeledData = kz_json:set_value(<<"origin">>, ?ACCOUNT_OUTBOUND_RECORDING_LABEL(ToNetwork), Data),
Expand Down
6 changes: 4 additions & 2 deletions core/kazoo_endpoint/src/kz_endpoint_recording.erl
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ maybe_record_inbound(FromNetwork, Endpoint, Call) ->
{'true', {kz_json:path(), kz_json:object()}} | 'false'.
maybe_record_inbound(_FromNetwork, _Endpoint, _Call, 'undefined') -> 'false';
maybe_record_inbound(FromNetwork, Endpoint, Call, Data) ->
case kz_json:is_true(<<"enabled">>, Data) of
case kz_json:is_true(<<"enabled">>, Data)
andalso not kapps_call:should_skip_feature_calls_recording(Call, Data) of
'false' -> 'false';
'true' ->
Values = [{<<"origin">>, <<"inbound from ", FromNetwork/binary, " to endpoint">>}],
Expand All @@ -551,7 +552,8 @@ maybe_record_outbound(ToNetwork, Endpoint, Call) ->
{'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
case kz_json:is_true(<<"enabled">>, Data)
andalso not kapps_call:should_skip_feature_calls_recording(Call, Data) of
'false' -> 'false';
'true' ->
LabeledData = kz_json:set_value(<<"origin">>, ?ENDPOINT_OUTBOUND_RECORDING_LABEL(ToNetwork), Data),
Expand Down