diff --git a/app/scripts/resources/scripts/app/xml_handler/index.lua b/app/scripts/resources/scripts/app/xml_handler/index.lua index 98388db919..677fc45a05 100644 --- a/app/scripts/resources/scripts/app/xml_handler/index.lua +++ b/app/scripts/resources/scripts/app/xml_handler/index.lua @@ -1,5 +1,5 @@ -- Part of FusionPBX --- Copyright (C) 2013 Mark J Crane +-- Copyright (C) 2013 - 2022 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -76,6 +76,7 @@ user_context = params:getHeader("variable_user_context"); call_context = params:getHeader("Caller-Context"); 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"); hunt_context = params:getHeader("Hunt-Context"); if (hunt_context ~= nil) then diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index 5049b064ba..d74097c51b 100644 --- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -1,6 +1,6 @@ -- xml_handler.lua -- Part of FusionPBX --- Copyright (C) 2013-2020 Mark J Crane +-- Copyright (C) 2013-2022 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -37,6 +37,37 @@ call_context = "public"; 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 dialplan_mode_key = "dialplan:mode"; dialplan_mode, err = cache.get(dialplan_mode_key); @@ -52,6 +83,11 @@ local ok, err = cache.set(dialplan_mode_key, dialplan_mode, expire["dialplan"]); end + --set the default + if (dialplan_mode == nil or dialplan_mode == '') then + dialplan_mode = "multiple"; + end + --send a message to the log if (debug['cache']) then log.notice(dialplan_mode_key.." source: database mode: "..dialplan_mode); @@ -82,6 +118,11 @@ dialplan_cache_key = "dialplan:" .. call_context .. ":" .. destination_number; 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 XML_STRING, err = cache.get(dialplan_cache_key); if (debug['cache']) then