summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common/call_forwarding.lua
diff options
context:
space:
mode:
Diffstat (limited to 'misc/freeswitch/scripts/common/call_forwarding.lua')
-rw-r--r--misc/freeswitch/scripts/common/call_forwarding.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/call_forwarding.lua b/misc/freeswitch/scripts/common/call_forwarding.lua
new file mode 100644
index 0000000..3942d05
--- /dev/null
+++ b/misc/freeswitch/scripts/common/call_forwarding.lua
@@ -0,0 +1,47 @@
+-- Gemeinschaft 5 module: call forwarding class
+-- (c) AMOOMA GmbH 2012
+--
+
+module(...,package.seeall)
+
+CallForwarding = {}
+
+-- Create CallForwarding object
+function CallForwarding.new(self, arg, object)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self);
+ self.__index = self
+ self.log = arg.log;
+ self.database = arg.database;
+ self.record = arg.record;
+ self.domain = arg.domain;
+ return object;
+end
+
+-- Find call forwarding by id
+function CallForwarding.find_by_id(self, id)
+ local sql_query = 'SELECT * FROM `call_forwards` WHERE `id`= ' .. tonumber(id) .. ' LIMIT 1';
+ local record = nil
+
+ self.database:query(sql_query, function(entry)
+ record = entry;
+ end)
+
+ if record then
+ call_forwarding = CallForwarding:new(self)
+ call_forwarding.record = record
+ return call_forwarding
+ end
+
+ return nil
+end
+
+function CallForwarding.presence_set(self, presence_state)
+ require 'dialplan.presence'
+ local presence = dialplan.presence.Presence:new();
+
+ presence:init{log = self.log, accounts = { 'f-cftg-' .. tostring(self.record.id) }, domain = self.domain, uuid = 'call_forwarding_' .. tostring(self.record.id)};
+
+ return presence:set(presence_state);
+end