diff options
Diffstat (limited to 'misc/freeswitch/scripts')
-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 |