diff options
author | spag <spag@golwen.net> | 2013-01-15 12:29:12 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-15 12:29:12 +0100 |
commit | 82ab2c07fbc494bad3ffdde30dbb3ce0d98c4e19 (patch) | |
tree | fd1c819a68faf79466c97d9901e29a0c3b523d0d /misc/freeswitch/scripts/common/gateway.lua | |
parent | 857f3de83628c1de8d1c65ce2aea36ab7bd8e8c5 (diff) |
gateway settings
Diffstat (limited to 'misc/freeswitch/scripts/common/gateway.lua')
-rw-r--r-- | misc/freeswitch/scripts/common/gateway.lua | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 9cddd7c..6e9fbfb 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -32,32 +32,22 @@ function Gateway.list(self, technology) end -function Gateway.find_by_sql(self, where) - local sql_query = 'SELECT * FROM `gateways` WHERE ' .. where .. ' LIMIT 1'; +function Gateway.find_by_id(self, id) + local sql_query = 'SELECT * FROM `gateways` WHERE `id`= ' .. tonumber(id) .. ' LIMIT 1'; local gateway = nil; self.database:query(sql_query, function(entry) gateway = Gateway:new(self); gateway.record = entry; gateway.id = tonumber(entry.id); - gateway.uuid = entry.uuid; + gateway.name = entry.name; end) - return gateway; -end - - --- find gateway by id -function Gateway.find_by_id(self, id) - local sql_query = '`id`= ' .. tonumber(id); - return self:find_by_sql(sql_query); -end - --- find gateway name -function Gateway.find_by_name(self, name) - local sql_query = '`name`= "' .. name .. '"'; + if gateway then + gateway.settings = self:config_table_get('gateway_settings', gateway.id); + end - return self:find_by_sql(sql_query); + return gateway; end @@ -140,6 +130,14 @@ function Gateway.parameters_build(self, gateway_id) parameters.password = settings.password; end + parameters['extension-in-contact'] = true; + + if common.str.blank(settings.contact) then + parameters['extension'] = 'gateway' .. gateway_id; + else + parameters['extension'] = settings.contact; + end + for key, value in pairs(self:config_table_get('gateway_parameters', gateway_id)) do parameters[key] = value; end |