Software /
code /
prosody
Changeset
10429:0b04d25c4ffb
mod_csi: Cache CSI module availability to improve readabilty
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 23 Nov 2019 17:15:34 +0100 |
parents | 10428:12a10208d86a |
children | 10430:46dd9df2db0c |
files | plugins/mod_csi.lua |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_csi.lua Sat Nov 23 17:09:48 2019 +0100 +++ b/plugins/mod_csi.lua Sat Nov 23 17:15:34 2019 +0100 @@ -2,8 +2,9 @@ local xmlns_csi = "urn:xmpp:csi:0"; local csi_feature = st.stanza("csi", { xmlns = xmlns_csi }); +local csi_handler_available = nil; module:hook("stream-features", function (event) - if event.origin.username and prosody.hosts[module.host].events._handlers["csi-client-active"] then + if event.origin.username and csi_handler_available then event.features:add_child(csi_feature); end end); @@ -23,8 +24,10 @@ function module.load() if prosody.hosts[module.host].events._handlers["csi-client-active"] then + csi_handler_available = true; module:set_status("core", "CSI handler module loaded"); else + csi_handler_available = false; module:set_status("warn", "No CSI handler module loaded"); end end