Enable ability to use sip_to_user. (#6406)
* Enable ability to use sip_to_user. * Set the sip_to_user variable. * Update index.lua
This commit is contained in:
parent
cf1aad072c
commit
d16dd2ae1e
|
|
@ -1,5 +1,5 @@
|
||||||
-- Part of FusionPBX
|
-- Part of FusionPBX
|
||||||
-- Copyright (C) 2013 Mark J Crane <markjcrane@fusionpbx.com>
|
-- Copyright (C) 2013 - 2022 Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
-- All rights reserved.
|
-- All rights reserved.
|
||||||
--
|
--
|
||||||
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -76,6 +76,7 @@
|
||||||
user_context = params:getHeader("variable_user_context");
|
user_context = params:getHeader("variable_user_context");
|
||||||
call_context = params:getHeader("Caller-Context");
|
call_context = params:getHeader("Caller-Context");
|
||||||
destination_number = params:getHeader("Caller-Destination-Number");
|
destination_number = params:getHeader("Caller-Destination-Number");
|
||||||
|
sip_to_user = params:getHeader("variable_sip_to_user");
|
||||||
caller_id_number = params:getHeader("Caller-Caller-ID-Number");
|
caller_id_number = params:getHeader("Caller-Caller-ID-Number");
|
||||||
hunt_context = params:getHeader("Hunt-Context");
|
hunt_context = params:getHeader("Hunt-Context");
|
||||||
if (hunt_context ~= nil) then
|
if (hunt_context ~= nil) then
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- xml_handler.lua
|
-- xml_handler.lua
|
||||||
-- Part of FusionPBX
|
-- Part of FusionPBX
|
||||||
-- Copyright (C) 2013-2020 Mark J Crane <markjcrane@fusionpbx.com>
|
-- Copyright (C) 2013-2022 Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
-- All rights reserved.
|
-- All rights reserved.
|
||||||
--
|
--
|
||||||
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -37,6 +37,37 @@
|
||||||
call_context = "public";
|
call_context = "public";
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--get the dialplan mode from the cache
|
||||||
|
dialplan_destination_key = "dialplan:destination";
|
||||||
|
dialplan_destination, err = cache.get(dialplan_destination_key);
|
||||||
|
|
||||||
|
--if not found in the cache then get it from the database
|
||||||
|
if (err == 'NOT FOUND') then
|
||||||
|
--get the mode from default settings
|
||||||
|
sql = "select default_setting_value from v_default_settings "
|
||||||
|
sql = sql .. "where default_setting_category = 'dialplan' ";
|
||||||
|
sql = sql .. "and default_setting_subcategory = 'destination' ";
|
||||||
|
dialplan_destination = dbh:first_value(sql, nil);
|
||||||
|
if (dialplan_destination) then
|
||||||
|
local ok, err = cache.set(dialplan_destination_key, dialplan_destination, expire["dialplan"]);
|
||||||
|
end
|
||||||
|
|
||||||
|
--set the default
|
||||||
|
if (dialplan_destination == nil or dialplan_destination == '') then
|
||||||
|
dialplan_destination = "destination_number";
|
||||||
|
end
|
||||||
|
|
||||||
|
--send a message to the log
|
||||||
|
if (debug['cache']) then
|
||||||
|
log.notice(dialplan_destination_key.." source: database destination: "..dialplan_destination);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--send a message to the log
|
||||||
|
if (debug['cache']) then
|
||||||
|
log.notice(dialplan_destination_key.." source: cache destination: "..dialplan_destination);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--get the dialplan mode from the cache
|
--get the dialplan mode from the cache
|
||||||
dialplan_mode_key = "dialplan:mode";
|
dialplan_mode_key = "dialplan:mode";
|
||||||
dialplan_mode, err = cache.get(dialplan_mode_key);
|
dialplan_mode, err = cache.get(dialplan_mode_key);
|
||||||
|
|
@ -52,6 +83,11 @@
|
||||||
local ok, err = cache.set(dialplan_mode_key, dialplan_mode, expire["dialplan"]);
|
local ok, err = cache.set(dialplan_mode_key, dialplan_mode, expire["dialplan"]);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--set the default
|
||||||
|
if (dialplan_mode == nil or dialplan_mode == '') then
|
||||||
|
dialplan_mode = "multiple";
|
||||||
|
end
|
||||||
|
|
||||||
--send a message to the log
|
--send a message to the log
|
||||||
if (debug['cache']) then
|
if (debug['cache']) then
|
||||||
log.notice(dialplan_mode_key.." source: database mode: "..dialplan_mode);
|
log.notice(dialplan_mode_key.." source: database mode: "..dialplan_mode);
|
||||||
|
|
@ -82,6 +118,11 @@
|
||||||
dialplan_cache_key = "dialplan:" .. call_context .. ":" .. destination_number;
|
dialplan_cache_key = "dialplan:" .. call_context .. ":" .. destination_number;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--use alternative sip_to_user instead of the default
|
||||||
|
if (dialplan_destination == '${sip_to_user}') then
|
||||||
|
destination_number = api:execute("url_decode", sip_to_user);
|
||||||
|
end
|
||||||
|
|
||||||
--get the cache
|
--get the cache
|
||||||
XML_STRING, err = cache.get(dialplan_cache_key);
|
XML_STRING, err = cache.get(dialplan_cache_key);
|
||||||
if (debug['cache']) then
|
if (debug['cache']) then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue