Browse Source

Adding a prosody module to support sip-style call flows.

When combined with mod_muc_poltergeist mod_muc_call allows
for enabling call features using a proper ext_events.lib.lua
implementation. By default when the module is configured only
stub implementations are used for ext_events.lib.lua as these
are unique between deployments.
master
Jacob MacElroy 7 years ago
parent
commit
01e0dfe58a

+ 17
- 0
resources/prosody-plugins/ext_events.lib.lua View File

@@ -0,0 +1,17 @@
1
+-- invite will perform the trigger for external call invites.
2
+-- This trigger is left unimplemented. The implementation is expected
3
+-- to be specific to the deployment.
4
+local function invite(stanza, url)
5
+   module:log(
6
+	  "warn",
7
+	  "A module has been configured that triggers external events."
8
+   )
9
+   module:log("warn", "Implement this lib to trigger external events.")
10
+end
11
+
12
+
13
+local ext_events = {
14
+   invite = invite
15
+}
16
+
17
+return ext_events

+ 64
- 0
resources/prosody-plugins/mod_muc_call.lua View File

@@ -0,0 +1,64 @@
1
+local ext_events = module:require "ext_events"
2
+local jid = require "util.jid"
3
+
4
+-- Options and configuration
5
+local poltergeist_component = module:get_option_string(
6
+   "poltergeist_component",
7
+   module.host
8
+);
9
+local muc_domain_base = module:get_option_string("muc_mapper_domain_base");
10
+if not muc_domain_base then
11
+   module:log(
12
+	  "warn",
13
+	  "No 'muc_domain_base' option set, unable to send call events."
14
+   );
15
+   return
16
+end
17
+
18
+-- Status strings that trigger call events.
19
+local invited_status = "Invited"
20
+
21
+-- url_from_room_jid will determine the url for a conference
22
+-- provided a room jid. It is required that muc domain mapping
23
+-- is enabled and configured. There are two url formats that are supported.
24
+-- The following urls are examples of the supported formats.
25
+--     https://meet.jit.si/jitsi/ProductiveMeeting
26
+--     https://meet.jit.si/MoreProductiveMeeting
27
+-- The urls are derived from portions of the room jid.
28
+local function url_from_room_jid(room_jid)
29
+   local node, _, _ = jid.split(room_jid)
30
+   if not node then return nil end
31
+
32
+   local target_subdomain, target_node = node:match("^%[([^%]]+)%](.+)$")
33
+
34
+   if not(target_node or target_subdomain) then
35
+	  return "https://"..muc_domain_base.."/"..node
36
+   else
37
+	  return
38
+		 "https://"..muc_domain_base.."/"..target_subdomain.."/"..target_node
39
+   end
40
+end
41
+
42
+-- Listening for all muc presences stanza events. If a presence stanza is from
43
+-- a poltergeist then it will be further processed to determine if a call
44
+-- event should be triggered. Call events are triggered by status strings
45
+-- the status strings supported are:
46
+--    -------------------------
47
+--    Status     | Event Type
48
+--    _________________________
49
+--    "Invited"  | Invite
50
+module:hook("muc-broadcast-presence", function (event)
51
+    -- Detect if the presence is for a poltergeist or not.
52
+    if not
53
+	   (jid.bare(event.occupant.jid) == poltergeist_component)
54
+	   or
55
+	   event.stanza == nil
56
+	then
57
+	   return
58
+    end
59
+
60
+    if event.stanza:get_child_text("status") == invited_status then
61
+	   local url = assert(url_from_room_jid(event.stanza.attr.from))
62
+	   ext_events.invite(event.stanza, url)
63
+    end
64
+end, -101);

Loading…
Cancel
Save