aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_csi.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-01 10:26:08 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-01 10:26:08 +0100
commit5d94b20a6267a2517d47b86af3063115b8b34425 (patch)
tree95329315752ec2800d49e145834556fadf9731ab /plugins/mod_csi.lua
parent89360a401bbe38b355c8c48cbb156d74994aecbb (diff)
downloadprosody-5d94b20a6267a2517d47b86af3063115b8b34425.tar.gz
prosody-5d94b20a6267a2517d47b86af3063115b8b34425.zip
mod_csi: Imported from prosody-modules 66b3085ecc49
Diffstat (limited to 'plugins/mod_csi.lua')
-rw-r--r--plugins/mod_csi.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/mod_csi.lua b/plugins/mod_csi.lua
new file mode 100644
index 00000000..03f052b7
--- /dev/null
+++ b/plugins/mod_csi.lua
@@ -0,0 +1,22 @@
+local st = require "util.stanza";
+local xmlns_csi = "urn:xmpp:csi:0";
+local csi_feature = st.stanza("csi", { xmlns = xmlns_csi });
+
+module:hook("stream-features", function (event)
+ if event.origin.username then
+ event.features:add_child(csi_feature);
+ end
+end);
+
+function refire_event(name)
+ return function (event)
+ if event.origin.username then
+ module:fire_event(name, event);
+ return true;
+ end
+ end;
+end
+
+module:hook("stanza/"..xmlns_csi..":active", refire_event("csi-client-active"));
+module:hook("stanza/"..xmlns_csi..":inactive", refire_event("csi-client-inactive"));
+