summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-17 12:45:23 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-17 12:45:23 +0100
commitd007b83d1d6b51caea93b5f08f449db88a930a16 (patch)
tree53c3ff07977cd374182358acef4b821a17e345b6 /misc
parent0ed2894ca7371199788c202b61f53a3f73c4b03b (diff)
parentabc16da2c2afa636a928a031a540e677f4ac84f8 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/conf/freeswitch.xml4
-rw-r--r--misc/freeswitch/scripts/common/log.lua14
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua9
-rw-r--r--misc/freeswitch/scripts/dialplan/hunt_group.lua27
-rw-r--r--misc/freeswitch/scripts/dialplan/router.lua11
-rw-r--r--misc/freeswitch/scripts/dialplan/sip_call.lua11
6 files changed, 57 insertions, 19 deletions
diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml
index b322ff5..97e027d 100644
--- a/misc/freeswitch/conf/freeswitch.xml
+++ b/misc/freeswitch/conf/freeswitch.xml
@@ -272,8 +272,10 @@
</input>
<input pattern="^name:(.+)$">
<match>
+ <action function="play-file" data="ivr/ivr-thank_you_for_calling.wav"/>
<action function="play-file" data="$1"/>
<action function="play-file" data="voicemail/vm-not_available.wav"/>
+ <action function="play-file" data="ivr/ivr-please_state_your_name_and_reason_for_calling.wav"/>
</match>
</input>
<input pattern="^greeting:(.+)$">
@@ -796,8 +798,10 @@
</input>
<input pattern="^name:(.+)$">
<match>
+ <action function="play-file" data="ivr/ivr-thank_you_for_calling.wav"/>
<action function="play-file" data="$1"/>
<action function="play-file" data="voicemail/vm-not_available.wav"/>
+ <action function="play-file" data="ivr/ivr-please_state_your_name_and_reason_for_calling.wav"/>
</match>
</input>
<input pattern="^greeting:(.+)$">
diff --git a/misc/freeswitch/scripts/common/log.lua b/misc/freeswitch/scripts/common/log.lua
index f224070..b9893ac 100644
--- a/misc/freeswitch/scripts/common/log.lua
+++ b/misc/freeswitch/scripts/common/log.lua
@@ -24,6 +24,7 @@ function Log.new(self, arg)
self.level_notice = arg.level_notice or 5;
self.level_info = arg.level_info or 6;
self.level_debug = arg.level_debug or 7;
+ self.level_devel = arg.level_devel or 4;
return object;
end
@@ -35,7 +36,12 @@ function Log.message(self, log_level, message_arguments )
local message = tostring(self.prefix);
for index, value in pairs(message_arguments) do
if type(index) == 'number' then
- message = message .. tostring(value);
+ if type(value) == 'table' then
+ require 'common.array';
+ message = message .. common.array.to_json(value);
+ else
+ message = message .. tostring(value);
+ end
end
end
if self.buffer then
@@ -76,3 +82,9 @@ end
function Log.debug(self, ...)
self:message(self.level_debug, {...});
end
+
+function Log.devel(self, ...)
+ local arguments = {...};
+ table.insert(arguments, 1, '**');
+ self:message(self.level_devel, arguments);
+end
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index e887610..9abd3d2 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -185,12 +185,15 @@ function Dialplan.retrieve_caller_data(self)
self.caller:set_auth_account(self.caller.auth_account);
end
else
- self.log:info('CALLER_DATA - no data - unauthenticated call: ', self.caller.auth_account_type, '/', self.caller.auth_account_uuid);
+ self.log:info('CALLER_DATA - no data - unauthenticated call: ', self.caller.auth_account_type, '=', self.caller.auth_account_id, '/', self.caller.auth_account_uuid);
end
if not common.str.blank(self.caller.account_type) and not common.str.blank(self.caller.account_uuid) then
self.caller.account = self:object_find{class = self.caller.account_type, uuid = self.caller.account_uuid};
if self.caller.account then
+ self.caller.clir = common.str.to_b(common.array.try(self.caller, 'account.record.clir'));
+ self.caller.clip = common.str.to_b(common.array.try(self.caller, 'account.record.clip'));
+
require 'common.phone_number'
self.caller.caller_phone_numbers = common.phone_number.PhoneNumber:new{ log = self.log, database = self.database }:list_by_owner(self.caller.account.id, self.caller.account.class);
for index, caller_number in ipairs(self.caller.caller_phone_numbers) do
@@ -623,6 +626,8 @@ function Dialplan.switch(self, destination)
local result = nil;
self.dial_timeout_active = self.dial_timeout;
+ self.log:debug('SWITCH - auth: ', self.caller.auth_account.class, '=', self.caller.auth_account.id, '/', self.caller.auth_account.uuid, ', caller: ', self.caller.account.class, '=', self.caller.account.id, '/', self.caller.account.uuid);
+
if not destination.node_local then
return self:dial(destination);
end
@@ -723,8 +728,8 @@ function Dialplan.switch(self, destination)
for index, number in ipairs(self.caller.caller_phone_numbers) do
table.insert(self.caller.caller_id_numbers, number);
end
- self.log:info('CALLER_ID_NUMBERS - clir: ', self.caller.clir, ', numbers: ', table.concat(self.caller.caller_id_numbers, ','));
+ self.log:info('SWITCH - clir: ', self.caller.clir, ', caller_id_numbers: ', table.concat(self.caller.caller_id_numbers, ','));
destination.callee_id_number = destination.number;
destination.callee_id_name = nil;
diff --git a/misc/freeswitch/scripts/dialplan/hunt_group.lua b/misc/freeswitch/scripts/dialplan/hunt_group.lua
index bff0a8e..b1728c3 100644
--- a/misc/freeswitch/scripts/dialplan/hunt_group.lua
+++ b/misc/freeswitch/scripts/dialplan/hunt_group.lua
@@ -38,7 +38,7 @@ end
function HuntGroup.find_by_uuid(self, uuid)
- local sql_query = 'SELECT * FROM `hunt_groups` WHERE `id`= "'.. uuid .. '" LIMIT 1';
+ local sql_query = 'SELECT * FROM `hunt_groups` WHERE `uuid`= "'.. uuid .. '" LIMIT 1';
local hunt_group = nil;
self.database:query(sql_query, function(entry)
@@ -98,25 +98,26 @@ function HuntGroup.run(self, dialplan_object, caller, destination)
self.log:info('HUNTGROUP ', self.record.id, ' - name: ', self.record.name, ', strategy: ', self.record.strategy,', members: ', #hunt_group_members);
- local clip_no_screening = common.array.try(caller, 'account.record.clip_no_screening');
caller.caller_id_numbers = {}
- if not common.str.blank(clip_no_screening) then
- for index, number in ipairs(common.str.strip_to_a(clip_no_screening, ',')) do
- table.insert(caller.caller_id_numbers, number);
- end
- end
for index, number in ipairs(caller.caller_phone_numbers) do
table.insert(caller.caller_id_numbers, number);
end
- self.log:info('CALLER_ID_NUMBERS - clir: ', caller.clir, ', numbers: ', table.concat(caller.caller_id_numbers, ','));
- local save_destination = caller.destination;
+ local phone_numbers = common.phone_number.PhoneNumber:new{ log = self.log, database = self.database }:list_by_owner(self.id, self.class);
+ for index, number in ipairs(phone_numbers) do
+ table.insert(caller.caller_id_numbers, number);
+ end
+
+ self.log:debug('HUNTGROUP ', self.record.id, ' - auth: ', caller.auth_account.class, '=', caller.auth_account.id, '/', caller.auth_account.uuid, ', caller: ', caller.account.class, '=', caller.account.id, '/', caller.account.uuid);
+ self.log:info('HUNTGROUP ', self.record.id, ' - clir: ', caller.clir, ', caller_id_numbers: ', table.concat(caller.caller_id_numbers, ','));
+
+ local hunt_group_destination = caller.destination;
local destinations = {}
for index, hunt_group_member in ipairs(hunt_group_members) do
local destination = dialplan_object:destination_new{ number = hunt_group_member.number };
if destination.type == 'unknown' then
-
+ caller.destination = destination;
caller.destination_number = destination.number;
require 'dialplan.router'
@@ -144,8 +145,8 @@ function HuntGroup.run(self, dialplan_object, caller, destination)
end
end
- caller.destination = save_destination;
- caller.destination_number = save_destination.number;
+ caller.destination = hunt_group_destination;
+ caller.destination_number = hunt_group_destination.number;
local forwarding_destination = nil;
if caller.forwarding_service == 'assistant' and caller.auth_account then
@@ -165,7 +166,7 @@ function HuntGroup.run(self, dialplan_object, caller, destination)
table.insert(recursive_destinations, forwarding_destination);
end
require 'dialplan.sip_call'
- result = dialplan.sip_call.SipCall:new{ log = self.log, database = self.database, caller = caller }:fork( recursive_destinations, { callee_id_number = destination.number, timeout = member_timeout });
+ result = dialplan.sip_call.SipCall:new{ log = self.log, database = self.database, caller = caller }:fork( recursive_destinations, { callee_id_number = hunt_group_destination.number, timeout = member_timeout });
if result.disposition == 'SUCCESS' then
if result.fork_index then
result.destination = recursive_destinations[result.fork_index];
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua
index 751d24f..c335186 100644
--- a/misc/freeswitch/scripts/dialplan/router.lua
+++ b/misc/freeswitch/scripts/dialplan/router.lua
@@ -83,11 +83,16 @@ function Router.element_match(self, pattern, search_string, replacement, route_v
end
-function Router.element_match_group(self, pattern, groups, replacement, use_key, route_variables)
+function Router.element_match_group(self, pattern, groups, replacement, use_key, route_variables, variable_name)
if type(groups) ~= 'table' then
+ self.log:debug('ELEMENT_FIND_IN_ARRAY - no such array: ', variable_name, ', use_keys: ', tostring(use_key));
return false;
end
+ if self.log_details then
+ self.log:debug('ELEMENT_FIND_IN_ARRAY - array: ', variable_name, ', use_keys: ', tostring(use_key));
+ end
+
for key, value in pairs(groups) do
if use_key then
value = key;
@@ -136,8 +141,8 @@ function Router.route_match(self, route)
local search_string = tostring(common.array.try(self.caller, element.var_in));
result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement));
elseif command == 'key' or command == 'val' then
- local groups = common.array.try(self.caller, variable_name);
- result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key');
+ local groups = common.array.try(destination, variable_name) or common.array.try(self.caller, variable_name);
+ result, replacement = self:element_match_group(tostring(element.pattern), groups, tostring(element.replacement), command == 'key', destination, variable_name);
elseif command == 'chv' then
local search_string = self.caller:to_s(variable_name);
result, replacement = self:element_match(tostring(element.pattern), search_string, tostring(element.replacement));
diff --git a/misc/freeswitch/scripts/dialplan/sip_call.lua b/misc/freeswitch/scripts/dialplan/sip_call.lua
index 5c98792..0cde601 100644
--- a/misc/freeswitch/scripts/dialplan/sip_call.lua
+++ b/misc/freeswitch/scripts/dialplan/sip_call.lua
@@ -135,6 +135,17 @@ function SipCall.fork(self, destinations, arg )
if destination.alert_info then
table.insert(origination_variables, "alert_info='" .. destination.alert_info .. "'");
end
+ if destination.account then
+ table.insert(origination_variables, "gs_account_type='" .. common.str.to_s(destination.account.class) .. "'");
+ table.insert(origination_variables, "gs_account_id='" .. common.str.to_i(destination.account.id) .. "'");
+ table.insert(origination_variables, "gs_account_uuid='" .. common.str.to_s(destination.account.uuid) .. "'");
+ end
+ if self.caller.auth_account then
+ table.insert(origination_variables, "gs_auth_account_type='" .. common.str.to_s(self.caller.auth_account.class) .. "'");
+ table.insert(origination_variables, "gs_auth_account_id='" .. common.str.to_i(self.caller.auth_account.id) .. "'");
+ table.insert(origination_variables, "gs_auth_account_uuid='" .. common.str.to_s(self.caller.auth_account.uuid) .. "'");
+ end
+
table.insert(dial_strings, '[' .. table.concat(origination_variables , ',') .. ']sofia/' .. sip_account.record.profile_name .. '/' .. sip_account.record.auth_name .. '%' .. sip_account.record.sip_host);
if destination.pickup_groups and #destination.pickup_groups > 0 then
for key=1, #destination.pickup_groups do