From 4087ff77797181d545ecb02c73365f7b5e096753 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 14 Feb 2014 01:01:51 +0000 Subject: [PATCH] Fix the call_direction. --- .../install/scripts/app/dialplan/index.lua | 38 +++++++++++---- .../resources/inbound/000_get_domain.lua | 44 ++++++++---------- .../resources/outbound/100_is_local.lua | 46 ++++++++----------- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/resources/install/scripts/app/dialplan/index.lua b/resources/install/scripts/app/dialplan/index.lua index 899b786892..a6388b3f89 100644 --- a/resources/install/scripts/app/dialplan/index.lua +++ b/resources/install/scripts/app/dialplan/index.lua @@ -1,9 +1,22 @@ +-- FusionPBX +-- Version: MPL 1.1 +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ ---include config.lua - --scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1)); - --dofile(scripts_dir.."/resources/functions/config.lua"); - --dofile(config()); +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. + +-- The Original Code is FusionPBX + +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Portions created by the Initial Developer are Copyright (C) 2014 +-- the Initial Developer. All Rights Reserved. --add functions dofile(scripts_dir.."/resources/functions/file_exists.lua"); @@ -17,19 +30,26 @@ --unix -- dir /usr/local/freeswitch/scripts -1 - --set local variables local context = session:getVariable("context"); local destination_number = session:getVariable("destination_number"); + local call_direction = session:getVariable("call_direction"); + local domain_name = session:getVariable("domain_name"); --determine the call direction if (context == "public") then call_direction = "inbound"; else - if (string.len(destination_number) > 6) then - call_direction = "outbound"; - else - call_direction = "local"; + if (call_direction == nil) then + if (context == "outbound@"..domain_name) then + call_direction = "outbound"; + else + if (string.len(destination_number) > 6) then + call_direction = "outbound"; + else + call_direction = "local"; + end + end end end diff --git a/resources/install/scripts/app/dialplan/resources/inbound/000_get_domain.lua b/resources/install/scripts/app/dialplan/resources/inbound/000_get_domain.lua index 67fab7a5f4..9a1d0a35bb 100644 --- a/resources/install/scripts/app/dialplan/resources/inbound/000_get_domain.lua +++ b/resources/install/scripts/app/dialplan/resources/inbound/000_get_domain.lua @@ -1,28 +1,22 @@ --- ring_groups.lua --- Part of FusionPBX --- Copyright (C) 2010-2013 Mark J Crane --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY --- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE --- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, --- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF --- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS --- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN --- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) --- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. +-- FusionPBX +-- Version: MPL 1.1 + +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ + +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. + +-- The Original Code is FusionPBX + +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Portions created by the Initial Developer are Copyright (C) 2014 +-- the Initial Developer. All Rights Reserved. --set defaults expire = {} diff --git a/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua b/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua index 37b2d97332..9284e08ee0 100644 --- a/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua +++ b/resources/install/scripts/app/dialplan/resources/outbound/100_is_local.lua @@ -1,28 +1,22 @@ --- ring_groups.lua --- Part of FusionPBX --- Copyright (C) 2010-2013 Mark J Crane --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY --- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE --- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, --- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF --- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS --- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN --- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) --- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. +-- FusionPBX +-- Version: MPL 1.1 + +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ + +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. + +-- The Original Code is FusionPBX + +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Portions created by the Initial Developer are Copyright (C) 2014 +-- the Initial Developer. All Rights Reserved. --set defaults expire = {} @@ -39,7 +33,7 @@ --get the cache cache = trim(api:execute("memcache", "get app:dialplan:outbound:is_local:" .. destination_number .. "@" .. domain_name)); ---get the ring group destinations +--get the destination number if (cache == "-ERR NOT FOUND") then sql = "SELECT destination_number, destination_context " sql = sql .. "FROM v_destinations "