Software /
code /
prosody
Comparison
plugins/mod_disco.lua @ 4337:a2ee8ab82dd9
core.modulemanager, mod_disco: Add support for XEP-0128: Service Discovery Extensions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 08 Aug 2011 18:23:53 +0200 |
parent | 3695:d2c4856c7ed5 |
child | 4985:0f72123ff513 |
comparison
equal
deleted
inserted
replaced
4336:abcbcb15205c | 4337:a2ee8ab82dd9 |
---|---|
52 if not done[feature] then | 52 if not done[feature] then |
53 query:tag("feature", {var=feature}):up(); | 53 query:tag("feature", {var=feature}):up(); |
54 done[feature] = true; | 54 done[feature] = true; |
55 end | 55 end |
56 end | 56 end |
57 for _,extension in ipairs(module:get_host_items("extension")) do | |
58 if not done[extension] then | |
59 query:add_child(extension); | |
60 done[extension] = true; | |
61 end | |
62 end | |
57 _cached_server_disco_info = query; | 63 _cached_server_disco_info = query; |
58 _cached_server_caps_hash = calculate_hash(query); | 64 _cached_server_caps_hash = calculate_hash(query); |
59 _cached_server_caps_feature = st.stanza("c", { | 65 _cached_server_caps_feature = st.stanza("c", { |
60 xmlns = "http://jabber.org/protocol/caps"; | 66 xmlns = "http://jabber.org/protocol/caps"; |
61 hash = "sha-1"; | 67 hash = "sha-1"; |
79 return _cached_server_caps_hash; | 85 return _cached_server_caps_hash; |
80 end | 86 end |
81 | 87 |
82 module:hook("item-added/identity", clear_disco_cache); | 88 module:hook("item-added/identity", clear_disco_cache); |
83 module:hook("item-added/feature", clear_disco_cache); | 89 module:hook("item-added/feature", clear_disco_cache); |
90 module:hook("item-added/extension", clear_disco_cache); | |
84 module:hook("item-removed/identity", clear_disco_cache); | 91 module:hook("item-removed/identity", clear_disco_cache); |
85 module:hook("item-removed/feature", clear_disco_cache); | 92 module:hook("item-removed/feature", clear_disco_cache); |
93 module:hook("item-removed/extension", clear_disco_cache); | |
86 | 94 |
87 -- Handle disco requests to the server | 95 -- Handle disco requests to the server |
88 module:hook("iq/host/http://jabber.org/protocol/disco#info:query", function(event) | 96 module:hook("iq/host/http://jabber.org/protocol/disco#info:query", function(event) |
89 local origin, stanza = event.origin, event.stanza; | 97 local origin, stanza = event.origin, event.stanza; |
90 if stanza.attr.type ~= "get" then return; end | 98 if stanza.attr.type ~= "get" then return; end |