From c8db7371bc31c6ef6ab27026d5f839c2095b924f Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 9 Jan 2013 11:10:04 +0100 Subject: read dialplan configuration from database --- misc/freeswitch/scripts/dialplan_default.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan_default.lua') diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index ee4a88f..91ad4e4 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -23,10 +23,18 @@ log = common.log.Log:new{ prefix = '### [' .. session:get_uuid() .. '] ' }; require 'dialplan.session' start_caller = dialplan.session.Session:new{ log = log, session = session }; +-- connect to database +require 'common.database' +local database = common.database.Database:new{ log = log }:connect(); +if not database:connected() then + log:critical('DIALPLAN_DEFAULT - database connect failed'); + return; +end + -- dialplan object require 'dialplan.dialplan' -start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller }; +start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; start_dialplan:configuration_read(); start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); @@ -39,16 +47,6 @@ if not start_dialplan:check_auth() then return false; end --- connect to database -require 'common.database' -local database = common.database.Database:new{ log = log }:connect(); -if not database:connected() then - log:critical('DIALPLAN_DEFAULT - database connect failed'); - return; -end - -start_dialplan.database = database; - if start_caller.from_node and not start_dialplan:check_auth_node() then log:debug('AUTHENTICATION_REQUIRED_NODE - node_id: ', start_caller.node_id, ', domain: ', start_dialplan.domain); start_dialplan:hangup(407, start_dialplan.domain); -- cgit v1.2.3