瀏覽代碼

feat(calls): Adding missed call event triggering.

j8
jmacelroy 6 年之前
父節點
當前提交
d189888902
共有 2 個文件被更改,包括 34 次插入17 次删除
  1. 26
    14
      resources/prosody-plugins/ext_events.lib.lua
  2. 8
    3
      resources/prosody-plugins/mod_muc_call.lua

+ 26
- 14
resources/prosody-plugins/ext_events.lib.lua 查看文件

@@ -1,29 +1,41 @@
1 1
 -- invite will perform the trigger for external call invites.
2 2
 -- This trigger is left unimplemented. The implementation is expected
3 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.")
4
+local function invite(stanza, url, call_id)
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 10
 end
11 11
 
12 12
 -- cancel will perform the trigger for external call cancellation.
13 13
 -- This trigger is left unimplemented. The implementation is expected
14 14
 -- to be specific to the deployment.
15
-local function cancel(stanza, url, reason)
16
-   module:log(
17
-	  "warn",
18
-	  "A module has been configured that triggers external events."
19
-   )
20
-   module:log("warn", "Implement this lib to trigger external events.")
15
+local function cancel(stanza, url, reason, call_id)
16
+    module:log(
17
+        "warn",
18
+        "A module has been configured that triggers external events."
19
+    )
20
+    module:log("warn", "Implement this lib to trigger external events.")
21
+end
22
+
23
+-- missed will perform the trigger for external call missed notification.
24
+-- This trigger is left unimplemented. The implementation is expected
25
+-- to be specific to the deployment.
26
+local function missed(stanza, call_id)
27
+    module:log(
28
+        "warn",
29
+        "A module has been configured that triggers external events."
30
+    )
31
+    module:log("warn", "Implement this lib to trigger external events.")
21 32
 end
22 33
 
23 34
 
24 35
 local ext_events = {
25
-   invite = invite,
26
-   cancel = cancel
36
+    missed = missed,
37
+    invite = invite,
38
+    cancel = cancel
27 39
 }
28 40
 
29 41
 return ext_events

+ 8
- 3
resources/prosody-plugins/mod_muc_call.lua 查看文件

@@ -20,8 +20,7 @@ local calling_status   = "calling"
20 20
 local busy_status      = "busy"
21 21
 local rejected_status  = "rejected"
22 22
 local connected_status = "connected"
23
-
24
-
23
+local expired_status   = "expired"
25 24
 
26 25
 -- url_from_room_jid will determine the url for a conference
27 26
 -- provided a room jid. It is required that muc domain mapping
@@ -92,6 +91,11 @@ module:hook(
92 91
             return
93 92
         end
94 93
 
94
+        local missed = function()
95
+            cancel()
96
+            ext_events.missed(event.stanza, call_id)
97
+        end
98
+
95 99
         -- All other call flow actions will require a status.
96 100
         if event.stanza:get_child_text("status") == nil then
97 101
             return
@@ -101,7 +105,8 @@ module:hook(
101 105
             case = {
102 106
                 [calling_status]   = function() invite() end,
103 107
                 [busy_status]      = function() cancel() end,
104
-                [rejected_status]  = function() cancel() end,
108
+                [rejected_status]  = function() missed() end,
109
+                [expired_status]   = function() missed() end,
105 110
                 [connected_status] = function() cancel() end
106 111
             }
107 112
             if case[status] then case[status]() end

Loading…
取消
儲存