Add. Flag to switch mode for building dial-string.

You can configure ether you register with UserID=number-alias or UserID=Extension
In both cases to dial user you should use `user/<number-alias>@domain` or `user_data <number-alias>@domain`

Need test setting of presence_id for case when UserID=Extension.
This commit is contained in:
Alexey Melnichuk 2015-08-21 16:43:25 +04:00
parent 9463beeaa0
commit 01127ded32
1 changed files with 8 additions and 5 deletions

View File

@ -62,15 +62,18 @@
--all other directory actions: sip_auth, user_call
--except for the action: group_call
-- Make sance only for extensions with number_alias
-- true - you should register with AuthID=Extension and UserID=Number Alias
-- false - you should register with AuthID=UserID=Extension
also in this case you need 2 records in memcache for one extension
local DIAL_STRING_BASED_ON_USERID = false
local sip_auth_method = params:getHeader("sip_auth_method")
if sip_auth_method then
sip_auth_method = sip_auth_method:upper();
end
local from_user = params:getHeader("sip_from_user")
if from_user == '' then
from_user = user
end
-- verify from_user and number alias for this methods
local METHODS = {
@ -306,7 +309,7 @@
else
--set a default dial string
if (dial_string == null) then
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. sip_from_number .. "@" .. domain_name .. ")}";
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. (DIAL_STRING_BASED_ON_USERID and sip_from_number or sip_from_user) .. "@" .. domain_name .. ")}";
end
--set the an alternative dial string if the hostnames don't match
if (load_balancing) then
@ -540,7 +543,7 @@
dbh:release();
--set the cache
local key = "directory:" .. sip_from_number .. "@" .. domain_name
local key = "directory:" .. (DIAL_STRING_BASED_ON_USERID and sip_from_number or sip_from_user) .. "@" .. domain_name
if debug['cache'] then
freeswitch.consoleLog("notice", "[xml_handler-directory][memcache] set key: " .. key .. "\n")
end