diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-12 09:23:55 -0400 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-12 09:23:55 -0400 |
commit | e4d13ea2a83dbfdbf7939be556196343af335bdb (patch) | |
tree | f812d1e157e675396f950c34d93b455629c14b04 /misc/freeswitch/scripts/event | |
parent | a2754c9a3bfd83cf9fcfb6a1bf7469507fb9e44c (diff) |
trigger rails on presence changes
Diffstat (limited to 'misc/freeswitch/scripts/event')
-rw-r--r-- | misc/freeswitch/scripts/event/presence_update.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/misc/freeswitch/scripts/event/presence_update.lua b/misc/freeswitch/scripts/event/presence_update.lua index 4d0cb94..7e9ea77 100644 --- a/misc/freeswitch/scripts/event/presence_update.lua +++ b/misc/freeswitch/scripts/event/presence_update.lua @@ -196,8 +196,8 @@ function PresenceUpdate.sip_account(self, inbound, account, domain, status, uuid self.account_record[account] = { id = sip_account.id, class = sip_account.class, phone_numbers = phone_numbers, created_at = os.time() } end - require 'dialplan.presence' - local result = dialplan.presence.Presence:new{ + require 'dialplan.presence'; + dialplan.presence.Presence:new{ log = self.log, database = self.database, inbound = inbound, @@ -205,12 +205,14 @@ function PresenceUpdate.sip_account(self, inbound, account, domain, status, uuid accounts = self.account_record[account].phone_numbers, uuid = uuid }:set(status_map[status] or 'terminated', caller_id); + + self:trigger_rails(self.account_record[account], status_map[status] or 'terminated', uuid); end function PresenceUpdate.conference(self, inbound, account, domain, status, uuid) - require 'dialplan.presence' - local result = dialplan.presence.Presence:new{ + require 'dialplan.presence'; + dialplan.presence.Presence:new{ log = self.log, database = self.database, inbound = inbound, @@ -219,3 +221,13 @@ function PresenceUpdate.conference(self, inbound, account, domain, status, uuid) uuid = uuid }:set(status or 'terminated'); end + + +function PresenceUpdate.trigger_rails(self, account, status, uuid) + if account.class == 'sipaccount' then + local command = 'http_request.lua ' .. uuid .. ' http://127.0.0.1/trigger/sip_account_update/' .. tostring(account.id .. '?status=' .. tostring(status)); + + require 'common.fapi' + common.fapi.FApi:new():execute('luarun', command); + end +end |