diff options
author | spag <spag@golwen.net> | 2013-01-18 12:10:48 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-18 12:10:48 +0100 |
commit | 3a91509c6c668cc634d667a2e1c7144873a39861 (patch) | |
tree | d359403efdfdcae1ab334f02c73c33cb66b72700 /misc/freeswitch/scripts/common/gateway.lua | |
parent | 045a4cfb6374cde4c664e91a9f8d1fede844b610 (diff) |
gateway find_by_name method added
Diffstat (limited to 'misc/freeswitch/scripts/common/gateway.lua')
-rw-r--r-- | misc/freeswitch/scripts/common/gateway.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/gateway.lua b/misc/freeswitch/scripts/common/gateway.lua index 5c76aba..e50c763 100644 --- a/misc/freeswitch/scripts/common/gateway.lua +++ b/misc/freeswitch/scripts/common/gateway.lua @@ -52,6 +52,27 @@ function Gateway.find_by_id(self, id) end +function Gateway.find_by_name(self, name) + local gateway_name = name:gsub('([^%a%d%._%+])', ''); + + local sql_query = 'SELECT * FROM `gateways` WHERE `name`= "' .. gateway_name .. '" 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.name = entry.name; + end) + + if gateway then + gateway.settings = self:config_table_get('gateway_settings', gateway.id); + end + + return gateway; +end + + function Gateway.authenticate(self, technology, caller) local sql_query = 'SELECT `c`.`name`, `c`.`id`, `a`.`value` `auth_source`, `b`.`value` `auth_pattern` \ FROM `gateway_settings` `a` \ |