comparison plugins/mod_csi.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parents 0b04d25c4ffb
children 74b9e05af71e
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
1 local st = require "util.stanza"; 1 local st = require "util.stanza";
2 local xmlns_csi = "urn:xmpp:csi:0"; 2 local xmlns_csi = "urn:xmpp:csi:0";
3 local csi_feature = st.stanza("csi", { xmlns = xmlns_csi }); 3 local csi_feature = st.stanza("csi", { xmlns = xmlns_csi });
4 4
5 local csi_handler_available = nil;
5 module:hook("stream-features", function (event) 6 module:hook("stream-features", function (event)
6 if event.origin.username then 7 if event.origin.username and csi_handler_available then
7 event.features:add_child(csi_feature); 8 event.features:add_child(csi_feature);
8 end 9 end
9 end); 10 end);
10 11
11 function refire_event(name) 12 function refire_event(name)
19 end 20 end
20 21
21 module:hook("stanza/"..xmlns_csi..":active", refire_event("csi-client-active")); 22 module:hook("stanza/"..xmlns_csi..":active", refire_event("csi-client-active"));
22 module:hook("stanza/"..xmlns_csi..":inactive", refire_event("csi-client-inactive")); 23 module:hook("stanza/"..xmlns_csi..":inactive", refire_event("csi-client-inactive"));
23 24
25 function module.load()
26 if prosody.hosts[module.host].events._handlers["csi-client-active"] then
27 csi_handler_available = true;
28 module:set_status("core", "CSI handler module loaded");
29 else
30 csi_handler_available = false;
31 module:set_status("warn", "No CSI handler module loaded");
32 end
33 end
34 module:hook("module-loaded", module.load);
35 module:hook("module-unloaded", module.load);