Mercurial > prosody-hg
comparison plugins/mod_disco.lua @ 11204:ae2a11066001
mod_disco: Add some spacing to improve readability and code navigation
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 10 Nov 2020 14:46:49 +0100 |
| parents | 80dbb60d81e4 |
| children | 59cf555b4698 |
comparison
equal
deleted
inserted
replaced
| 11203:d10f59ac7f74 | 11204:ae2a11066001 |
|---|---|
| 69 hash = "sha-1"; | 69 hash = "sha-1"; |
| 70 node = "http://prosody.im"; | 70 node = "http://prosody.im"; |
| 71 ver = _cached_server_caps_hash; | 71 ver = _cached_server_caps_hash; |
| 72 }); | 72 }); |
| 73 end | 73 end |
| 74 | |
| 74 local function clear_disco_cache() | 75 local function clear_disco_cache() |
| 75 _cached_server_disco_info, _cached_server_caps_feature, _cached_server_caps_hash = nil, nil, nil; | 76 _cached_server_disco_info, _cached_server_caps_feature, _cached_server_caps_hash = nil, nil, nil; |
| 76 end | 77 end |
| 77 local function get_server_disco_info() | 78 local function get_server_disco_info() |
| 78 if not _cached_server_disco_info then build_server_disco_info(); end | 79 if not _cached_server_disco_info then build_server_disco_info(); end |
| 114 reply_query.attr.node = node; | 115 reply_query.attr.node = node; |
| 115 local reply = st.reply(stanza):add_child(reply_query); | 116 local reply = st.reply(stanza):add_child(reply_query); |
| 116 origin.send(reply); | 117 origin.send(reply); |
| 117 return true; | 118 return true; |
| 118 end); | 119 end); |
| 120 | |
| 119 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function(event) | 121 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function(event) |
| 120 local origin, stanza = event.origin, event.stanza; | 122 local origin, stanza = event.origin, event.stanza; |
| 121 local node = stanza.tags[1].attr.node; | 123 local node = stanza.tags[1].attr.node; |
| 122 if node and node ~= "" then | 124 if node and node ~= "" then |
| 123 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#items', node=node}); | 125 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#items', node=node}); |
| 177 module:fire_event("account-disco-info", { origin = origin, reply = reply }); | 179 module:fire_event("account-disco-info", { origin = origin, reply = reply }); |
| 178 origin.send(reply); | 180 origin.send(reply); |
| 179 return true; | 181 return true; |
| 180 end | 182 end |
| 181 end); | 183 end); |
| 184 | |
| 182 module:hook("iq-get/bare/http://jabber.org/protocol/disco#items:query", function(event) | 185 module:hook("iq-get/bare/http://jabber.org/protocol/disco#items:query", function(event) |
| 183 local origin, stanza = event.origin, event.stanza; | 186 local origin, stanza = event.origin, event.stanza; |
| 184 local node = stanza.tags[1].attr.node; | 187 local node = stanza.tags[1].attr.node; |
| 185 local username = jid_split(stanza.attr.to) or origin.username; | 188 local username = jid_split(stanza.attr.to) or origin.username; |
| 186 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then | 189 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then |
| 202 module:fire_event("account-disco-items", { origin = origin, stanza = stanza, reply = reply }); | 205 module:fire_event("account-disco-items", { origin = origin, stanza = stanza, reply = reply }); |
| 203 origin.send(reply); | 206 origin.send(reply); |
| 204 return true; | 207 return true; |
| 205 end | 208 end |
| 206 end); | 209 end); |
| 210 |
