From 22673442f323370bdce72594203d451ad8d1212f Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Thu, 14 Aug 2014 01:21:55 +0000 Subject: [PATCH] Fix recordings per extension for ring groups --- app/ring_groups/ring_group_edit.php | 3 +- .../install/scripts/app/ring_groups/index.lua | 47 +++++++++++++++++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 6a56f2c539..77119c24f1 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -546,7 +546,7 @@ else { echo " \n"; echo " \n"; echo " \n"; @@ -558,7 +558,6 @@ else { } echo " \n"; echo " \n"; - $x++; } echo " \n"; diff --git a/resources/install/scripts/app/ring_groups/index.lua b/resources/install/scripts/app/ring_groups/index.lua index d7f24cc093..0a92a1f6bb 100644 --- a/resources/install/scripts/app/ring_groups/index.lua +++ b/resources/install/scripts/app/ring_groups/index.lua @@ -1,6 +1,6 @@ -- ring_groups.lua -- Part of FusionPBX --- Copyright (C) 2010-2013 Mark J Crane +-- Copyright (C) 2010-2014 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -28,7 +28,6 @@ -- Mark J Crane -- Luis Daniel Lucio Qurioz - --connect to the database dofile(scripts_dir.."/resources/functions/database_handle.lua"); dbh = database_handle('system'); @@ -56,6 +55,7 @@ source = session:getVariable("source"); uuid = session:getVariable("uuid"); context = session:getVariable("context"); + call_direction = session:getVariable("call_direction"); --define additional variables uuids = ""; @@ -69,6 +69,20 @@ if (not default_dialect) then default_dialect = 'us'; end if (not default_voice) then default_voice = 'callie'; end +--get record_ext + if (session:getVariable("record_ext")) then + record_ext = session:getVariable("record_ext"); + else + record_ext = "wav"; + end + +--set the recording path + recording_archive = recordings_dir + if (domain_count > 1) then + recording_archive = recording_archive.."/"..domain_name; + end + recording_archive = recording_archive.."/archive/"..(os.date("%Y")).."/"..(os.date("%b")).."/"..(os.date("%d")); + --prepare the api object api = freeswitch.API(); @@ -100,7 +114,7 @@ --set confirm -- session:execute("set", "group_confirm_key=exec"); -- session:execute("set", "group_confirm_file=lua ".. scripts_dir .."/confirm.lua"); - + --process the ring group if (ring_group_forward_enabled == "true" and string.len(ring_group_forward_destination) > 0) then --forward the ring group @@ -114,7 +128,7 @@ and d.ring_group_uuid = ']]..ring_group_uuid..[[' and r.ring_group_enabled = 'true' order by d.destination_delay, d.destination_number asc ]] - freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); destinations = {}; x = 1; assert(dbh:query(sql, function(row) @@ -244,6 +258,29 @@ group_confirm = ""; end + --get user_record value and determine whether to record the session + cmd = "user_data ".. destination_number .."@"..domain_name.." var user_record"; + user_record = trim(api:executeString(cmd)); + --set the record_session variable + if (user_record == "all") then + record_session = true; + end + if (user_record == "inbound" and call_direction == "inbound") then + record_session = true; + end + if (user_record == "outbound" and call_direction == "outbound") then + record_session = true; + end + if (user_record == "local" and call_direction == "local") then + record_session = true; + end + + --record the session + if (record_session) then + cmd = "uuid_record "..uuid.." start "..recording_archive.."/"..uuid.."."..record_ext; + response = api:executeString(cmd); + end + --process according to user_exists, sip_uri, external number if (user_exists == "true") then --get the extension_uuid @@ -449,4 +486,4 @@ --table.insert(ACTIONS, {"set", "hangup_after_bridge=true"}); --table.insert(ACTIONS, {"set", "continue_on_fail=true"}); --table.insert(ACTIONS, {"bridge", app_data}); - --table.insert(ACTIONS, {ring_group_timeout_app, ring_group_timeout_data}); + --table.insert(ACTIONS, {ring_group_timeout_app, ring_group_timeout_data}); \ No newline at end of file