diff --git a/kamailio/dispatcher-role.cfg b/kamailio/dispatcher-role.cfg index 9cee94e..90c779f 100644 --- a/kamailio/dispatcher-role.cfg +++ b/kamailio/dispatcher-role.cfg @@ -71,8 +71,20 @@ route[DISPATCHER_FIND_ROUTES] if (is_method("INVITE")) { + $var(replaced_call_id) = "none"; + + if( $(ou{uri.param,kazoo-id}{s.len}) > 0) { + if($hdr(Replaces)== $null) { + $var(replaced_call_id) = $(ou{uri.param,kazoo-id}{s.unescape.param}); + append_hf("Replaces: $var(replaced_call_id)\r\n"); + } + } + if($hdr(Replaces)!= $null) { $var(replaced_call_id) = $(hdr(Replaces){s.select,0,;}); + } + + if($var(replaced_call_id) != "none") { xlog("L_INFO", "$ci|log|replaces call-id $var(replaced_call_id)"); $var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "channel_status_req", "Call-ID" : "' + $var(replaced_call_id) + '", "Active-Only" : true }'; $var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode}); @@ -83,15 +95,30 @@ route[DISPATCHER_FIND_ROUTES] return; } } - } - - ##### CALL-PARK #### - if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { - $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); - $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; - xlog("L_INFO", "$ci|log|redirecting park request to $du"); - return; - } + } + + ##### CALL-PARK #### + if($(ru{uri.user}) =~ "\*3" && $sht(park=>$(ru{uri.user})@$(ru{uri.domain})) != $null) { + $du = $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})); + $sht(park=>$(ru{uri.user})@$(ruri{uri.domain})) = $null; + xlog("L_INFO", "$ci|log|redirecting park request to $du"); + return; + } + + + ##### CALL-PARK IN KAZOO #### + if($(ru{uri.user}) =~ "\*3" && !($rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") ) { + xlog("L_INFO", "$ci|log|checking park request to $(ru{uri.user})@$(ru{uri.domain})"); + $var(amqp_payload_request) = '{"Event-Category" : "call_event" , "Event-Name" : "query_user_channels_req", "Username" : "$(ru{uri.user})", "Realm" : "$(ru{uri.domain})", "Active-Only" : true }'; + $var(amqp_routing_key) = "call.status_req." + $(var(replaced_call_id){kz.encode}); + if(kazoo_query("callevt", $var(amqp_routing_key), $var(amqp_payload_request))) { + $du = $(kzR{kz.json,Channels[0].switch_url}); + if($du != $null) { + xlog("L_INFO", "$ci|log|redirecting park request to $du, courtesy of kazoo"); + return; + } + } + } }