Skip to content

Commit

Permalink
add gateway ccvs (2600hz#6488)
Browse files Browse the repository at this point in the history
* these were already allowed in the schema but were not sent
  • Loading branch information
lazedo authored Apr 22, 2020
1 parent 5077b8b commit de8f1e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions applications/stepswitch/src/stepswitch_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
,rtcp_mux = <<>> :: binary()
,caller_id_type = <<"external">> :: kz_term:ne_binary()
,fax_option :: kz_term:ne_binary() | boolean()
,ccvs :: kz_term:api_object()
,sip_headers :: kz_term:api_object()
,sip_interface :: kz_term:api_binary()
,progress_timeout = 8 :: 1..100
Expand Down Expand Up @@ -682,6 +683,7 @@ gateway_to_endpoint(DestinationNumber
,username=Username
,password=Password
,realm=AuthRealm
,ccvs=GatewayCCVs
,sip_headers=SipHeaders
,sip_interface=SipInterface
,endpoint_type=EndpointType
Expand All @@ -698,12 +700,14 @@ gateway_to_endpoint(DestinationNumber

RequestorCCVs = kz_json:get_ne_json_value(<<"Requestor-Custom-Channel-Vars">>, OffnetJObj, kz_json:new()),

CCVs = [{<<"Emergency-Resource">>, IsEmergency}
KVs = [{<<"Emergency-Resource">>, IsEmergency}
,{<<"Matched-Number">>, DestinationNumber}
,{<<"Resource-Type">>, <<"offnet-termination">>}
,{<<"RTCP-MUX">>, RTCP_MUX}
| gateway_from_uri_settings(Gateway)
],
CCVs = kz_json:set_values(KVs, GatewayCCVs),

kz_json:from_list(
props:filter_empty(
[{<<"Route">>, gateway_dialstring(Gateway, DestinationNumber)}
Expand All @@ -722,7 +726,7 @@ gateway_to_endpoint(DestinationNumber
,{<<"Endpoint-Type">>, EndpointType}
,{<<"Endpoint-Options">>, EndpointOptions}
,{<<"Endpoint-Progress-Timeout">>, kz_term:to_binary(ProgressTimeout)}
,{<<"Custom-Channel-Vars">>, kz_json:from_list(CCVs)}
,{<<"Custom-Channel-Vars">>, CCVs}
,{<<"Outbound-Caller-ID-Number">>, CIDNumber}
,{<<"Outbound-Caller-ID-Name">>, CIDName}
,{<<"SIP-Invite-Parameters">>, sip_invite_parameters(Gateway, OffnetJObj)}
Expand Down Expand Up @@ -1214,6 +1218,7 @@ gateway_from_jobj(GatewayJObj, #resrc{is_emergency=IsEmergency
,realm = kz_json:get_value(<<"realm">>, GatewayJObj)
,username = kz_json:get_value(<<"username">>, GatewayJObj)
,password = kz_json:get_value(<<"password">>, GatewayJObj)
,ccvs = gateway_ccvs(GatewayJObj)
,sip_headers = kz_custom_sip_headers:outbound(kz_json:get_json_value(<<"custom_sip_headers">>, GatewayJObj, kz_json:new()))
,sip_interface = kz_json:get_ne_value(<<"custom_sip_interface">>, GatewayJObj)
,invite_format = kz_json:get_value(<<"invite_format">>, GatewayJObj, <<"route">>)
Expand All @@ -1238,6 +1243,11 @@ gateway_from_jobj(GatewayJObj, #resrc{is_emergency=IsEmergency
,invite_parameters=kz_json:get_ne_value(<<"invite_parameters">>, GatewayJObj)
}.

-spec gateway_ccvs(kz_json:object()) -> kz_json:object().
gateway_ccvs(JObj) ->
CCVs = kz_json:get_json_value(<<"custom_channel_vars">>, JObj, kz_json:new()),
kz_custom_sip_headers:outbound(CCVs, kz_json:new()).

-spec gateway_is_emergency(kz_json:object(), boolean()) -> boolean().
gateway_is_emergency(_, 'true') -> 'true';
gateway_is_emergency(JObj, IsEmergency) ->
Expand Down

0 comments on commit de8f1e2

Please sign in to comment.