Skip to content

Commit

Permalink
PISTON-1290 added the ability to be able to skip call recording for f…
Browse files Browse the repository at this point in the history
…eature calls.
  • Loading branch information
Alexey Khabulyak committed Jun 25, 2021
1 parent 70372ba commit 41ddb19
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 4 deletions.
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
17 changes: 17 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
,maybe_skip_feature_calls_recording/2
]).

-export([is_recording/1, set_is_recording/2]).
Expand Down Expand Up @@ -1609,6 +1610,22 @@ 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 maybe_skip_feature_calls_recording(call(), kz_term:api_object()) -> boolean().
maybe_skip_feature_calls_recording(Call, Data) ->
try binary:first(callee_id_number(Call)) == 42
andalso not kz_json:is_true(<<"record_feature_code_calls">>, Data, 'true')
catch
_:_ -> 'false'
end.

-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:maybe_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:maybe_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:maybe_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:maybe_skip_feature_calls_recording(Call, Data) of
'false' -> 'false';
'true' ->
LabeledData = kz_json:set_value(<<"origin">>, ?ENDPOINT_OUTBOUND_RECORDING_LABEL(ToNetwork), Data),
Expand Down

0 comments on commit 41ddb19

Please sign in to comment.