Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Adding cancel to mod_muc_call

Jacob MacElroyf60559fb67f6
diff --git a/resources/prosody-plugins/ext_events.lib.lua b/resources/prosody-plugins/ext_events.lib.lua
index bdb6e3f418..1b48e2aa8b 100644
--- a/resources/prosody-plugins/ext_events.lib.lua
+++ b/resources/prosody-plugins/ext_events.lib.lua
@@ -9,9 +9,21 @@ local function invite(stanza, url)
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.")
+end
+
local ext_events = {
- invite = invite
+ 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 df725490fb..280d71df10 100644
--- a/resources/prosody-plugins/mod_muc_call.lua
+++ b/resources/prosody-plugins/mod_muc_call.lua
@@ -16,7 +16,14 @@ if not muc_domain_base then
end
-- Status strings that trigger call events.
-local invited_status = "Invited"
+local invited_status = "Invited"
+local calling_status = "Calling"
+local ringing_status = "Ringing"
+local busy_status = "Busy"
+local rejected_status = "Rejected"
+local connected_status = "connected"
+
+
-- url_from_room_jid will determine the url for a conference
-- provided a room jid. It is required that muc domain mapping
@@ -44,9 +51,14 @@ end
-- event should be triggered. Call events are triggered by status strings
-- the status strings supported are:
-- -------------------------
--- Status | Event Type
+-- Status | Event Type
-- _________________________
--- "Invited" | Invite
+-- "Calling" | INVITE
+-- "Invited" | INVITE
+-- "Ringing" | CANCEL
+-- "Busy" | CANCEL
+-- "Rejected" | CANCEL
+-- "connected" | CANCEL
module:hook("muc-broadcast-presence", function (event)
-- Detect if the presence is for a poltergeist or not.
if not
@@ -57,8 +69,28 @@ module:hook("muc-broadcast-presence", function (event)
return
end
- if event.stanza:get_child_text("status") == invited_status then
+ local invite = function()
+ local url = assert(url_from_room_jid(event.stanza.attr.from))
+ ext_events.invite(event.stanza, url)
+ end
+
+ local cancel = function()
local url = assert(url_from_room_jid(event.stanza.attr.from))
- ext_events.invite(event.stanza, url)
- end
+ local status = event.stanza:get_child_text("status")
+ ext_events.cancel(event.stanza, url, string.lower(status))
+ end
+
+ local switch = function(status)
+ case = {
+ [invited_status] = function() invite() end,
+ [calling_status] = function() invite() end,
+ [ringing_status] = function() cancel() end,
+ [busy_status] = function() cancel() end,
+ [rejected_status] = function() cancel() end,
+ [connected_status] = function() cancel() end
+ }
+ if case[status] then case[status]() end
+ end
+
+ switch(event.stanza:get_child_text("status"))
end, -101);