summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-21 11:03:47 +0100
committerspag <spag@golwen.net>2013-02-21 11:03:47 +0100
commit972bdbb01785be4d645cfd472ef43c779aaa70b9 (patch)
tree57717f68025c58a1066723764474372515e93aed /misc
parentdb436013b94cd7a565fde96baba37677d3884d8d (diff)
cpai function added
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/dialplan/functions.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua
index acfa336..e65aa32 100644
--- a/misc/freeswitch/scripts/dialplan/functions.lua
+++ b/misc/freeswitch/scripts/dialplan/functions.lua
@@ -113,6 +113,8 @@ function Functions.dialplan_function(self, caller, dialed_number)
result = self:hangup(caller, parameters[3], parameters[4]);
elseif fid == "cpa" then
result = self:call_parking_inout(caller, parameters[3], parameters[4]);
+ elseif fid == "cpai" then
+ result = self:call_parking_inout_index(caller, parameters[3]);
end
return result;
@@ -932,3 +934,39 @@ function Functions.call_parking_inout(self, caller, stall_name, lot_name)
return { continue = false, code = 200, phrase = 'OK', no_cdr = true }
end
+
+
+function Functions.call_parking_inout_index(self, caller, stall_index)
+ if not tonumber(stall_index) then
+ self.log:notice('FUNCTION_CALL_PARKING_INOUT_INDEX - malformed index: ', stall_index);
+ return { continue = false, code = 404, phrase = 'No parkings stall specified', no_cdr = true }
+ end
+
+ require 'common.str';
+ local owner = common.str.try(caller, 'auth_account.owner');
+
+ if not owner then
+ self.log:notice('FUNCTION_CALL_PARKING_INOUT_INDEX - stall owner not specified');
+ return { continue = false, code = 404, phrase = 'No parkings stalls owner' , no_cdr = true }
+ end
+
+ require 'dialplan.call_parking';
+ local parking_stalls = dialplan.call_parking.CallParking:new{ log = self.log, database = self.database, caller = caller }:find_by_owner(owner.id, owner.class);
+
+ if not parking_stalls or #parking_stalls < 1 then
+ self.log:notice('FUNCTION_CALL_PARKING_INOUT_INDEX - no parkings stalls found');
+ return { continue = false, code = 404, phrase = 'No parkings stalls', no_cdr = true }
+ end
+
+ local parking_stall = parking_stalls[tonumber(stall_index)];
+
+ if not parking_stall then
+ self.log:notice('FUNCTION_CALL_PARKING_INOUT_INDEX - no parkings stall found with index: ', stall_index);
+ return { continue = false, code = 404, phrase = 'Parking stall not found', no_cdr = true }
+ end
+
+ self.log:info('FUNCTION_CALL_PARKING_INOUT_INDEX parking/retrieving call - parkingstall=', parking_stall.id, '/', parking_stall.name, ', index: ', stall_index);
+ parking_stall:park_retrieve();
+
+ return { continue = false, code = 200, phrase = 'OK', no_cdr = true }
+end