From 279f194b399a7c069e4f35309b8aa4a46f3b6960 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 22 Sep 2015 19:33:41 +0400 Subject: [PATCH 1/9] Fix. Intercept enterprise ring group. With enterprise call each outbound channel has its own call_uuid. But we have to use `intercept` for call_uuid of inbound channel. --- .../install/scripts/app/ring_groups/index.lua | 15 ++++++++++++++ resources/install/scripts/intercept.lua | 11 +++++++--- resources/install/scripts/intercept_group.lua | 18 +++++++++++++---- .../resources/functions/channel_utils.lua | 20 +++++++++++++++++++ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 resources/install/scripts/resources/functions/channel_utils.lua diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index 31a31ee532..3a99d108af 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -27,6 +27,8 @@ -- Mark J Crane -- Luis Daniel Lucio Qurioz +local log = require "resources.functions.log".ring_group + --connect to the database require "resources.functions.database_handle"; dbh = database_handle('system'); @@ -618,10 +620,23 @@ end freeswitch.consoleLog("NOTICE", "[ring group] app_data: "..app_data.."\n"); session:execute("bridge", app_data); + -- log.noticef("bridge done: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false") end --timeout destination if (app_data ~= nil) then + if ring_group_strategy == "enterprise" + and ( true + --- I see 2 errors here `failure` and `PICKED_OFF` + --- but they be more. I think check `answered` is enough. + -- or session:getVariable("originate_disposition") == "failure" + -- or session:getVariable("originate_disposition") == "PICKED_OFF" + ) + and session:answered() then + -- for enterprise calls when intercept we get "failure" but session answered + return + end + if (session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT" or session:getVariable("originate_disposition") == "NO_ANSWER" or session:getVariable("originate_disposition") == "NO_USER_RESPONSE" diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index d6845a940b..a18f0d17b5 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -48,6 +48,7 @@ --add the function require "resources.functions.trim"; + require "resources.functions.channel_utils"; --exits the script if we didn't connect properly assert(dbh:connected()); @@ -119,7 +120,7 @@ if ( session:ready() ) then callee_num = ''; --check the database to get the uuid of a ringing call - sql = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels "; + sql = "select uuid, call_uuid, hostname, callee_num, ip_addr from channels "; sql = sql .. "where callstate in ('RINGING', 'EARLY') "; --sql = sql .. "AND direction = 'outbound' "; if (extension) then @@ -132,11 +133,15 @@ if ( session:ready() ) then if (debug["sql"]) then freeswitch.consoleLog("NOTICE", "sql "..sql.."\n"); end - dbh:query(sql, function(result) + dbh:query(sql, function(result) --for key, val in pairs(result) do -- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); --end - uuid = result.uuid; + if result.uuid == result.call_uuid then + uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or row.uuid + else + uuid = result.call_uuid; + end call_hostname = result.hostname; callee_num = result.callee_num; end); diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 32b1f4ef17..4db4e8793b 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -35,11 +35,19 @@ --add the function require "resources.functions.explode"; + require "resources.functions.trim"; + require "resources.functions.channel_utils"; + +--prepare the api object + api = freeswitch.API(); --connect to the database require "resources.functions.database_handle"; dbh = database_handle('system'); +--get the hostname + hostname = trim(api:execute("switchname", "")); + --check if the session is ready if ( session:ready() ) then --answer the session @@ -163,7 +171,7 @@ --check the database to get the uuid of a ringing call call_hostname = ""; - sql = "SELECT call_uuid AS uuid, hostname, ip_addr FROM channels "; + sql = "SELECT uuid, call_uuid, hostname, ip_addr FROM channels "; sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') "; --sql = sql .. "AND direction = 'outbound' "; sql = sql .. "AND ("; @@ -189,14 +197,16 @@ --for key, val in pairs(row) do -- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n"); --end - uuid = row.uuid; + if row.uuid == row.call_uuid then + uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or row.uuid + else + uuid = row.call_uuid; + end call_hostname = row.hostname; ip_addr = row.ip_addr; end); end ---get the hostname - hostname = freeswitch.getGlobalVariable("hostname"); freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n"); --intercept a call that is ringing diff --git a/resources/install/scripts/resources/functions/channel_utils.lua b/resources/install/scripts/resources/functions/channel_utils.lua new file mode 100644 index 0000000000..a078939d2e --- /dev/null +++ b/resources/install/scripts/resources/functions/channel_utils.lua @@ -0,0 +1,20 @@ + +local api = api or freeswitch.API() + +function channel_variable(uuid, name) + local result = api:executeString("uuid_getvar " .. uuid .. " " .. name) + + if result:sub(1, 4) == '-ERR' then return nil, result end + if result == '_undef_' then return false end + + return result +end + +function channel_evalute(uuid, cmd) + local result = api:executeString("eval uuid:" .. uuid .. " " .. cmd) + + if result:sub(1, 4) == '-ERR' then return nil, result end + if result == '_undef_' then return false end + + return result +end From 8720866ce9f4800b519407ea51fe892fff5e84fc Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 23 Sep 2015 13:08:22 +0400 Subject: [PATCH 2/9] Add. intercept for call center calls --- resources/install/scripts/intercept.lua | 4 +++- resources/install/scripts/intercept_group.lua | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index a18f0d17b5..7f0d8bdca3 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -138,7 +138,9 @@ if ( session:ready() ) then -- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); --end if result.uuid == result.call_uuid then - uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or row.uuid + uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or + channel_variable(result.uuid, 'cc_member_session_uuid') or + result.uuid else uuid = result.call_uuid; end diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 4db4e8793b..4ba42b71be 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -198,7 +198,9 @@ -- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n"); --end if row.uuid == row.call_uuid then - uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or row.uuid + uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or + channel_variable(row.uuid, 'cc_member_session_uuid') or + row.uuid else uuid = row.call_uuid; end From 9e538f4b717cd03983860f48d1ec30bda52ed90c Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Wed, 23 Sep 2015 14:40:05 +0400 Subject: [PATCH 3/9] Add. intercept for fifo calls --- resources/install/scripts/intercept.lua | 1 + resources/install/scripts/intercept_group.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index 7f0d8bdca3..a7a6695731 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -140,6 +140,7 @@ if ( session:ready() ) then if result.uuid == result.call_uuid then uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or channel_variable(result.uuid, 'cc_member_session_uuid') or + channel_variable(result.uuid, 'fifo_bridge_uuid') or result.uuid else uuid = result.call_uuid; diff --git a/resources/install/scripts/intercept_group.lua b/resources/install/scripts/intercept_group.lua index 4ba42b71be..845666c96e 100644 --- a/resources/install/scripts/intercept_group.lua +++ b/resources/install/scripts/intercept_group.lua @@ -200,6 +200,7 @@ if row.uuid == row.call_uuid then uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or channel_variable(row.uuid, 'cc_member_session_uuid') or + channel_variable(row.uuid, 'fifo_bridge_uuid') or row.uuid else uuid = row.call_uuid; From c5036298b87a2483001c144e62acebb61ce3240e Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:09:58 +0200 Subject: [PATCH 4/9] do not display voicemail sql debug messages --- .../app/voicemail/resources/functions/message_waiting.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua index 176910f5a6..7143b7625d 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua @@ -32,7 +32,7 @@ sql = [[SELECT extension, number_alias from v_extensions WHERE domain_uuid = ']] .. domain_uuid ..[[' AND (mwi_account = ']]..voicemail_id..[[' or mwi_account = ']]..voicemail_id..[[@]]..domain_name..[[')]]; - --if (debug["sql"]) then + if (debug["sql"]) then freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n"); --end status = dbh:query(sql, function(row) @@ -74,4 +74,4 @@ event:addHeader("MWI-Voice-Message", message_count.."/0 ("..message_count.."/0)"); event:fire(); end - end \ No newline at end of file + end From 29ec9f7d1883ac08f336202cf09c3acdf9d901a8 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 13:13:55 +0200 Subject: [PATCH 5/9] forgot commenting out end --- .../app/voicemail/resources/functions/message_waiting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua index 7143b7625d..b1225075bc 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/message_waiting.lua @@ -34,7 +34,7 @@ AND (mwi_account = ']]..voicemail_id..[[' or mwi_account = ']]..voicemail_id..[[@]]..domain_name..[[')]]; if (debug["sql"]) then freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n"); - --end + end status = dbh:query(sql, function(row) if (string.len(row["number_alias"]) > 0) then table.insert(accounts, row["number_alias"]); From 590a8e6505856c05c923d6269e4ac3e952b5f772 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:11:38 +0200 Subject: [PATCH 6/9] prepared img tag for high resolution (retina) images --- app/xml_cdr/xml_cdr.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 83a15eb7ad..a667148085 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -471,21 +471,21 @@ else { switch ($row['direction']) { case "inbound" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; case "outbound" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; case "local" : if ($row['billsec'] == 0) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; break; default: echo " "; From e47632f8d9bf989d7bc4184f73a2395f3199ed06 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 01:09:29 +0200 Subject: [PATCH 7/9] fixed fax destination with * or + in number --- resources/switch.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index ff873d1ca7..a6b97eb273 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -500,7 +500,8 @@ function outbound_route_to_bridge ($domain_uuid, $destination_number) { global $db; $destination_number = trim($destination_number); - if (is_numeric($destination_number)) { + preg_match('/^[\*\+0-9]*$/', $destination_number, $matches, PREG_OFFSET_CAPTURE); + if (count($matches) > 0) { //not found, continue to process the function } else { @@ -1442,4 +1443,4 @@ if (!function_exists('save_switch_xml')) { } } -?> \ No newline at end of file +?> From 442c760f04cf4259a5f91603dde295a866384302 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Tue, 1 Sep 2015 00:21:23 +0200 Subject: [PATCH 8/9] fixed provisioning with http_domain_filter off --- app/provision/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/provision/index.php b/app/provision/index.php index edd3b02cc2..fa20304c10 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -77,6 +77,7 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); $domain_uuid = $row["domain_uuid"]; } unset($result, $prep_statement); + $_SESSION['domain_uuid'] = $domain_uuid; //get the domain name $domain_name = $_SESSION['domains'][$domain_uuid]['domain_name']; @@ -311,4 +312,4 @@ openlog("fusion-provisioning", LOG_PID | LOG_PERROR, LOG_LOCAL0); return $needed_parts ? false : $data; } -?> \ No newline at end of file +?> From 451017603981504362f24a3d1611b71404bb9e74 Mon Sep 17 00:00:00 2001 From: "roman.dissauer" Date: Thu, 24 Sep 2015 09:00:51 +0200 Subject: [PATCH 9/9] latest german translations --- app/fifo/app_menu.php | 8 ++++---- app/follow_me/app_menu.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/fifo/app_menu.php b/app/fifo/app_menu.php index 136a9c66a7..23d13ed651 100644 --- a/app/fifo/app_menu.php +++ b/app/fifo/app_menu.php @@ -3,9 +3,9 @@ $apps[$x]['menu'][0]['title']['en-us'] = "Queues"; $apps[$x]['menu'][0]['title']['es-cl'] = "Colas"; $apps[$x]['menu'][0]['title']['es-mx'] = "Colas"; -$apps[$x]['menu'][0]['title']['de-de'] = ""; -$apps[$x]['menu'][0]['title']['de-ch'] = ""; -$apps[$x]['menu'][0]['title']['de-at'] = ""; +$apps[$x]['menu'][0]['title']['de-de'] = "Warteschlangen"; +$apps[$x]['menu'][0]['title']['de-ch'] = "Warteschlangen"; +$apps[$x]['menu'][0]['title']['de-at'] = "Warteschlangen"; $apps[$x]['menu'][0]['title']['fr-fr'] = "Queues"; $apps[$x]['menu'][0]['title']['fr-ca'] = ""; $apps[$x]['menu'][0]['title']['fr-ch'] = ""; @@ -19,4 +19,4 @@ $apps[$x]['menu'][0]['path'] = "/app/dialplan/dialplans.php?app_uuid=16589224-c8 $apps[$x]['menu'][0]['groups'][] = "admin"; $apps[$x]['menu'][0]['groups'][] = "superadmin"; -?> \ No newline at end of file +?> diff --git a/app/follow_me/app_menu.php b/app/follow_me/app_menu.php index 15e922e343..6054e217f0 100644 --- a/app/follow_me/app_menu.php +++ b/app/follow_me/app_menu.php @@ -2,9 +2,9 @@ $apps[$x]['menu'][0]['title']['en-us'] = "Follow Me"; $apps[$x]['menu'][0]['title']['es-mx'] = "Sígueme"; - $apps[$x]['menu'][0]['title']['de-de'] = ""; - $apps[$x]['menu'][0]['title']['de-ch'] = ""; - $apps[$x]['menu'][0]['title']['de-at'] = ""; + $apps[$x]['menu'][0]['title']['de-de'] = "Follow Me"; + $apps[$x]['menu'][0]['title']['de-ch'] = "Follow Me"; + $apps[$x]['menu'][0]['title']['de-at'] = "Follow Me"; $apps[$x]['menu'][0]['title']['fr-fr'] = "Follow Me"; $apps[$x]['menu'][0]['title']['fr-ca'] = ""; $apps[$x]['menu'][0]['title']['fr-ch'] = ""; @@ -18,4 +18,4 @@ $apps[$x]['menu'][0]['groups'][] = "admin"; $apps[$x]['menu'][0]['groups'][] = "superadmin"; -?> \ No newline at end of file +?>