Skip to content

Commit

Permalink
Merge 77a636d into 595a867
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anderson committed Jan 31, 2019
2 parents 595a867 + 77a636d commit 5143084
Show file tree
Hide file tree
Showing 21 changed files with 461 additions and 76 deletions.
39 changes: 31 additions & 8 deletions applications/callflow/src/module/cf_resources.erl
Expand Up @@ -105,6 +105,8 @@ handle_bridge_failure(Cause, Code, Call) ->
-spec build_offnet_request(kz_json:object(), kapps_call:call()) -> kz_term:proplist().
build_offnet_request(Data, Call) ->
{ECIDNum, ECIDName} = kz_attributes:caller_id(<<"emergency">>, Call),
{AssertedNumber, AssertedName, AssertedRealm} =
get_asserted_identity(Data, Call),
{CIDNumber, CIDName} = get_caller_id(Data, Call),
props:filter_undefined(
[{?KEY_ACCOUNT_ID, kapps_call:account_id(Call)}
Expand Down Expand Up @@ -132,6 +134,9 @@ build_offnet_request(Data, Call) ->
,{?KEY_OUTBOUND_CALLER_ID_NAME, CIDName}
,{?KEY_OUTBOUND_CALLER_ID_NUMBER, CIDNumber}
,{?KEY_PRESENCE_ID, maybe_presence_id(Call)}
,{?KEY_ASSERTED_IDENTITY_NAME, AssertedName}
,{?KEY_ASSERTED_IDENTITY_NUMBER, AssertedNumber}
,{?KEY_ASSERTED_IDENTITY_REALM, AssertedRealm}
,{?KEY_RESOURCE_TYPE, ?RESOURCE_TYPE_AUDIO}
,{?KEY_RINGBACK, kz_json:get_ne_binary_value(<<"ringback">>, Data)}
,{?KEY_T38_ENABLED, get_t38_enabled(Call)}
Expand Down Expand Up @@ -209,7 +214,7 @@ maybe_get_call_from_realm(Call) ->

-spec maybe_set_bridge_generate_comfort_noise(kapps_call:call(), kz_term:proplist()) -> kz_term:proplist().
maybe_set_bridge_generate_comfort_noise(Call, Acc) ->
case kz_endpoint:get(Call) of
case get_endpoint(Call) of
{'ok', Endpoint} ->
maybe_has_comfort_noise_option_enabled(Endpoint, Acc);
{'error', _E} ->
Expand All @@ -224,11 +229,26 @@ maybe_has_comfort_noise_option_enabled(Endpoint, Acc) ->
'false' -> Acc
end.

-spec get_caller_id(kz_json:object(), kapps_call:call()) -> {kz_term:api_binary(), kz_term:api_binary()}.
-spec get_caller_id(kz_json:object(), kapps_call:call()) ->
{kz_term:api_binary(), kz_term:api_binary()}.
get_caller_id(Data, Call) ->
Type = kz_json:get_value(<<"caller_id_type">>, Data, <<"external">>),
kz_attributes:caller_id(Type, Call).

-spec get_asserted_identity(kz_json:object(), kapps_call:call()) ->
{kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()}.
get_asserted_identity(_Data, Call) ->
case get_endpoint(Call) of
{'error', _E} -> {'undefined', 'undefined', 'undefined'};
{'ok', Endpoint} ->
DefaultRealm = kapps_call:account_realm(Call),
CallerId = kzd_devices:caller_id(Endpoint),
{kzd_caller_id:asserted_number(CallerId)
,kzd_caller_id:asserted_name(CallerId)
,kzd_caller_id:asserted_realm(CallerId, DefaultRealm)
}
end.

-spec get_hunt_account_id(kz_json:object(), kapps_call:call()) -> kz_term:api_binary().
get_hunt_account_id(Data, Call) ->
case kz_json:is_true(<<"use_local_resources">>, Data, 'true') of
Expand All @@ -250,11 +270,7 @@ get_request_did(Data, Call) ->
case kz_json:is_true(<<"do_not_normalize">>, Data) of
'true' -> get_original_request_user(Call);
'false' ->
AuthId = kapps_call:authorizing_id(Call),
EndpointId = kapps_call:kvs_fetch(?RESTRICTED_ENDPOINT_KEY, AuthId, Call),
case EndpointId =/= 'undefined'
andalso kz_endpoint:get(EndpointId, kapps_call:account_db(Call))
of
case get_endpoint(Call) of
{'ok', Endpoint} -> maybe_apply_dialplan(Endpoint, Data, Call);
_Else -> maybe_bypass_e164(Data, Call)
end
Expand Down Expand Up @@ -365,6 +381,13 @@ get_flow_dynamic_flags(Data, Call, Flags) ->
get_inception(Call) ->
kz_json:get_value(<<"Inception">>, kapps_call:custom_channel_vars(Call)).


-spec get_endpoint(kapps_call:call()) -> kz_endpoint:std_return().
get_endpoint(Call) ->
AuthId = kapps_call:authorizing_id(Call),
EndpointId = kapps_call:kvs_fetch(?RESTRICTED_ENDPOINT_KEY, AuthId, Call),
kz_endpoint:get(EndpointId, kapps_call:account_db(Call)).

%%------------------------------------------------------------------------------
%% @doc Consume Erlang messages and return on offnet response
%% @end
Expand Down Expand Up @@ -418,7 +441,7 @@ check_inception(Call) ->

-spec get_privacy_prefs_from_endpoint(kapps_call:call()) -> kz_term:proplist().
get_privacy_prefs_from_endpoint(Call) ->
get_privacy_prefs_from_endpoint(Call, kz_endpoint:get(Call)).
get_privacy_prefs_from_endpoint(Call, get_endpoint(Call)).

-spec get_privacy_prefs_from_endpoint(kapps_call:call(), {'ok', kz_json:object()} | {'error', any()}) -> kz_term:proplist().
get_privacy_prefs_from_endpoint(Call, {'ok', Endpoint}) ->
Expand Down
10 changes: 7 additions & 3 deletions applications/crossbar/doc/ref/accounts.md
Expand Up @@ -104,14 +104,18 @@ Defines caller ID settings based on the type of call being made

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`asserted.name` | The asserted identity name for the object type | `string(0..35)` | | `false` |
`asserted.number` | The asserted identity number for the object type | `string(0..35)` | | `false` |
`asserted.realm` | The asserted identity realm for the object type | `string()` | | `false` |
`asserted` | Used to convey the proven identity of the originator of a request within a trusted network. | `object()` | | `false` |
`emergency.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`emergency` | The caller ID used when a resource is flagged as 'emergency' | `object()` | | `false` |
`external.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`external` | The default caller ID used when dialing external numbers | `object()` | | `false` |
`internal.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`internal` | The default caller ID used when dialing internal extensions | `object()` | | `false` |

### dialplans
Expand Down
10 changes: 7 additions & 3 deletions applications/crossbar/doc/ref/devices.md
Expand Up @@ -128,14 +128,18 @@ Defines caller ID settings based on the type of call being made

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`asserted.name` | The asserted identity name for the object type | `string(0..35)` | | `false` |
`asserted.number` | The asserted identity number for the object type | `string(0..35)` | | `false` |
`asserted.realm` | The asserted identity realm for the object type | `string()` | | `false` |
`asserted` | Used to convey the proven identity of the originator of a request within a trusted network. | `object()` | | `false` |
`emergency.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`emergency` | The caller ID used when a resource is flagged as 'emergency' | `object()` | | `false` |
`external.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`external` | The default caller ID used when dialing external numbers | `object()` | | `false` |
`internal.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`internal` | The default caller ID used when dialing internal extensions | `object()` | | `false` |

### custom_sip_headers
Expand Down
10 changes: 7 additions & 3 deletions applications/crossbar/doc/ref/users.md
Expand Up @@ -116,14 +116,18 @@ Defines caller ID settings based on the type of call being made

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`asserted.name` | The asserted identity name for the object type | `string(0..35)` | | `false` |
`asserted.number` | The asserted identity number for the object type | `string(0..35)` | | `false` |
`asserted.realm` | The asserted identity realm for the object type | `string()` | | `false` |
`asserted` | Used to convey the proven identity of the originator of a request within a trusted network. | `object()` | | `false` |
`emergency.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`emergency.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`emergency` | The caller ID used when a resource is flagged as 'emergency' | `object()` | | `false` |
`external.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`external.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`external` | The default caller ID used when dialing external numbers | `object()` | | `false` |
`internal.name` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id name for the object type | `string(0..35)` | | `false` |
`internal.number` | The caller id number for the object type | `string(0..35)` | | `false` |
`internal` | The default caller ID used when dialing internal extensions | `object()` | | `false` |

### dialplans
Expand Down
71 changes: 68 additions & 3 deletions applications/crossbar/priv/api/swagger.json
Expand Up @@ -1255,6 +1255,26 @@
"caller_id": {
"description": "Defines caller ID settings based on the type of call being made",
"properties": {
"asserted": {
"description": "Used to convey the proven identity of the originator of a request within a trusted network.",
"properties": {
"name": {
"description": "The asserted identity name for the object type",
"maxLength": 35,
"type": "string"
},
"number": {
"description": "The asserted identity number for the object type",
"maxLength": 35,
"type": "string"
},
"realm": {
"description": "The asserted identity realm for the object type",
"type": "string"
}
},
"type": "object"
},
"emergency": {
"description": "The caller ID used when a resource is flagged as 'emergency'",
"properties": {
Expand All @@ -1264,7 +1284,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand All @@ -1280,7 +1300,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand All @@ -1296,7 +1316,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand Down Expand Up @@ -11581,6 +11601,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"items": {
"enum": [
Expand Down Expand Up @@ -19501,6 +19530,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"items": {
"enum": [
Expand Down Expand Up @@ -21140,6 +21178,15 @@
"Application-Data": {
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"type": "string"
},
Expand Down Expand Up @@ -21376,6 +21423,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"type": "string"
},
Expand Down Expand Up @@ -22907,6 +22963,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"type": "string"
},
Expand Down
26 changes: 23 additions & 3 deletions applications/crossbar/priv/couchdb/schemas/caller_id.json
Expand Up @@ -3,6 +3,26 @@
"_id": "caller_id",
"description": "Defines caller ID settings based on the type of call being made",
"properties": {
"asserted": {
"description": "Used to convey the proven identity of the originator of a request within a trusted network.",
"properties": {
"name": {
"description": "The asserted identity name for the object type",
"maxLength": 35,
"type": "string"
},
"number": {
"description": "The asserted identity number for the object type",
"maxLength": 35,
"type": "string"
},
"realm": {
"description": "The asserted identity realm for the object type",
"type": "string"
}
},
"type": "object"
},
"emergency": {
"description": "The caller ID used when a resource is flagged as 'emergency'",
"properties": {
Expand All @@ -12,7 +32,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand All @@ -28,7 +48,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand All @@ -44,7 +64,7 @@
"type": "string"
},
"number": {
"description": "The caller id name for the object type",
"description": "The caller id number for the object type",
"maxLength": 35,
"type": "string"
}
Expand Down
Expand Up @@ -9,6 +9,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"items": {
"enum": [
Expand Down
Expand Up @@ -23,6 +23,15 @@
],
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"items": {
"enum": [
Expand Down
Expand Up @@ -9,6 +9,15 @@
"Application-Data": {
"type": "string"
},
"Asserted-Identity-Name": {
"type": "string"
},
"Asserted-Identity-Number": {
"type": "string"
},
"Asserted-Identity-Realm": {
"type": "string"
},
"B-Leg-Events": {
"type": "string"
},
Expand Down

0 comments on commit 5143084

Please sign in to comment.