From d189888902ca6f00073d9ae248f677513c0abc6e Mon Sep 17 00:00:00 2001 From: jmacelroy Date: Wed, 11 Jul 2018 20:49:11 +0000 Subject: [PATCH] feat(calls): Adding missed call event triggering. --- resources/prosody-plugins/ext_events.lib.lua | 40 +++++++++++++------- resources/prosody-plugins/mod_muc_call.lua | 11 ++++-- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/resources/prosody-plugins/ext_events.lib.lua b/resources/prosody-plugins/ext_events.lib.lua index 1b48e2aa8..064beb757 100644 --- a/resources/prosody-plugins/ext_events.lib.lua +++ b/resources/prosody-plugins/ext_events.lib.lua @@ -1,29 +1,41 @@ -- invite will perform the trigger for external call invites. -- This trigger is left unimplemented. The implementation is expected -- to be specific to the deployment. -local function invite(stanza, url) - module:log( - "warn", - "A module has been configured that triggers external events." - ) - module:log("warn", "Implement this lib to trigger external events.") +local function invite(stanza, url, call_id) + module:log( + "warn", + "A module has been configured that triggers external events." + ) + module:log("warn", "Implement this lib to trigger external events.") end -- cancel will perform the trigger for external call cancellation. -- This trigger is left unimplemented. The implementation is expected -- to be specific to the deployment. -local function cancel(stanza, url, reason) - module:log( - "warn", - "A module has been configured that triggers external events." - ) - module:log("warn", "Implement this lib to trigger external events.") +local function cancel(stanza, url, reason, call_id) + module:log( + "warn", + "A module has been configured that triggers external events." + ) + module:log("warn", "Implement this lib to trigger external events.") +end + +-- missed will perform the trigger for external call missed notification. +-- This trigger is left unimplemented. The implementation is expected +-- to be specific to the deployment. +local function missed(stanza, call_id) + module:log( + "warn", + "A module has been configured that triggers external events." + ) + module:log("warn", "Implement this lib to trigger external events.") end local ext_events = { - invite = invite, - cancel = cancel + missed = missed, + invite = invite, + cancel = cancel } return ext_events diff --git a/resources/prosody-plugins/mod_muc_call.lua b/resources/prosody-plugins/mod_muc_call.lua index e6f714aea..e1b80608d 100644 --- a/resources/prosody-plugins/mod_muc_call.lua +++ b/resources/prosody-plugins/mod_muc_call.lua @@ -20,8 +20,7 @@ local calling_status = "calling" local busy_status = "busy" local rejected_status = "rejected" local connected_status = "connected" - - +local expired_status = "expired" -- url_from_room_jid will determine the url for a conference -- provided a room jid. It is required that muc domain mapping @@ -92,6 +91,11 @@ module:hook( return end + local missed = function() + cancel() + ext_events.missed(event.stanza, call_id) + end + -- All other call flow actions will require a status. if event.stanza:get_child_text("status") == nil then return @@ -101,7 +105,8 @@ module:hook( case = { [calling_status] = function() invite() end, [busy_status] = function() cancel() end, - [rejected_status] = function() cancel() end, + [rejected_status] = function() missed() end, + [expired_status] = function() missed() end, [connected_status] = function() cancel() end } if case[status] then case[status]() end