Software / code / prosody
Comparison
plugins/mod_csi.lua @ 9073:a5daf3f6d588
mod_csi: Imported from prosody-modules 66b3085ecc49
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 01 Aug 2018 10:26:08 +0100 |
| child | 9651:989cf872d5c0 |
comparison
equal
deleted
inserted
replaced
| 9072:9603a6a1ec85 | 9073:a5daf3f6d588 |
|---|---|
| 1 local st = require "util.stanza"; | |
| 2 local xmlns_csi = "urn:xmpp:csi:0"; | |
| 3 local csi_feature = st.stanza("csi", { xmlns = xmlns_csi }); | |
| 4 | |
| 5 module:hook("stream-features", function (event) | |
| 6 if event.origin.username then | |
| 7 event.features:add_child(csi_feature); | |
| 8 end | |
| 9 end); | |
| 10 | |
| 11 function refire_event(name) | |
| 12 return function (event) | |
| 13 if event.origin.username then | |
| 14 module:fire_event(name, event); | |
| 15 return true; | |
| 16 end | |
| 17 end; | |
| 18 end | |
| 19 | |
| 20 module:hook("stanza/"..xmlns_csi..":active", refire_event("csi-client-active")); | |
| 21 module:hook("stanza/"..xmlns_csi..":inactive", refire_event("csi-client-inactive")); | |
| 22 |