From 07b28588527fcd3f937a8472f4edf9cc5049d68d Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 18 Apr 2016 16:06:27 +0300 Subject: [PATCH] Add. optional intercept only inbound/outbound calls. Note. * `inbound` is call to some extension * `outbound` is call from some extension to external number. Currently there no way to find call from extension to extension as `outbound` --- resources/install/scripts/intercept.lua | 16 ++++++++++++++-- resources/install/scripts/intercept_group.lua | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index 54ea5a9f7c..fd982ee438 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -25,6 +25,7 @@ --user defined variables local extension = argv[1]; + local direction = argv[2] or extension and 'inbound' or 'all'; -- we can use any number because other box should check sip_h_X_*** headers first local pickup_number = '*8' -- extension and '**' or '*8' @@ -254,9 +255,20 @@ -- next check should prevent pickup call from extension -- e.g. if extension 100 dial some cell phone and some one else dial *8 -- he can pickup this call. - if not extension then - sql = sql .. "AND direction = 'outbound' "; + if not direction:find('all') then + sql = sql .. "AND (1 <> 1 " + -- calls from freeswitch to user + if direction:find('inbound') then + sql = sql .. "OR direction = 'outbound' "; + end + + -- calls from user to freeswitch + if direction:find('outbound') then + sql = sql .. "OR direction = 'inbound' "; + end + sql = sql .. ")" end + sql = sql .. "AND (1<>1 "; for key,extension in pairs(extensions) do sql = sql .. "OR presence_id = '"..extension.."@"..domain_name.."' "; diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index db4db46d05..719ce586b4 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -15,4 +15,7 @@ -- The Original Code is FusionPBX -- +-- shift arguments + argv[1], argv[2] = nil, argv[1] + require "intercept"