Mercurial > prosody-hg
comparison plugins/mod_disco.lua @ 8041:3b2cc22e9b5b
mod_disco: Rename variables to avoid name clash [luacheck]
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 01 Apr 2017 22:30:37 +0200 |
| parents | 15973ade9a11 |
| children | 745e0a783055 |
comparison
equal
deleted
inserted
replaced
| 8040:62c540d51d50 | 8041:3b2cc22e9b5b |
|---|---|
| 99 local origin, stanza = event.origin, event.stanza; | 99 local origin, stanza = event.origin, event.stanza; |
| 100 if stanza.attr.type ~= "get" then return; end | 100 if stanza.attr.type ~= "get" then return; end |
| 101 local node = stanza.tags[1].attr.node; | 101 local node = stanza.tags[1].attr.node; |
| 102 if node and node ~= "" and node ~= "http://prosody.im#"..get_server_caps_hash() then | 102 if node and node ~= "" and node ~= "http://prosody.im#"..get_server_caps_hash() then |
| 103 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node}); | 103 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node}); |
| 104 local event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; | 104 local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; |
| 105 local ret = module:fire_event("host-disco-info-node", event); | 105 local ret = module:fire_event("host-disco-info-node", node_event); |
| 106 if ret ~= nil then return ret; end | 106 if ret ~= nil then return ret; end |
| 107 if event.exists then | 107 if node_event.exists then |
| 108 origin.send(reply); | 108 origin.send(reply); |
| 109 else | 109 else |
| 110 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); | 110 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); |
| 111 end | 111 end |
| 112 return true; | 112 return true; |
| 121 local origin, stanza = event.origin, event.stanza; | 121 local origin, stanza = event.origin, event.stanza; |
| 122 if stanza.attr.type ~= "get" then return; end | 122 if stanza.attr.type ~= "get" then return; end |
| 123 local node = stanza.tags[1].attr.node; | 123 local node = stanza.tags[1].attr.node; |
| 124 if node and node ~= "" then | 124 if node and node ~= "" then |
| 125 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}); |
| 126 local event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; | 126 local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; |
| 127 local ret = module:fire_event("host-disco-items-node", event); | 127 local ret = module:fire_event("host-disco-items-node", node_event); |
| 128 if ret ~= nil then return ret; end | 128 if ret ~= nil then return ret; end |
| 129 if event.exists then | 129 if node_event.exists then |
| 130 origin.send(reply); | 130 origin.send(reply); |
| 131 else | 131 else |
| 132 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); | 132 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); |
| 133 end | 133 end |
| 134 return true; | 134 return true; |
| 161 local username = jid_split(stanza.attr.to) or origin.username; | 161 local username = jid_split(stanza.attr.to) or origin.username; |
| 162 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then | 162 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then |
| 163 if node and node ~= "" then | 163 if node and node ~= "" then |
| 164 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node}); | 164 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node}); |
| 165 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account | 165 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account |
| 166 local event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; | 166 local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; |
| 167 local ret = module:fire_event("account-disco-info-node", event); | 167 local ret = module:fire_event("account-disco-info-node", node_event); |
| 168 if ret ~= nil then return ret; end | 168 if ret ~= nil then return ret; end |
| 169 if event.exists then | 169 if node_event.exists then |
| 170 origin.send(reply); | 170 origin.send(reply); |
| 171 else | 171 else |
| 172 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); | 172 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); |
| 173 end | 173 end |
| 174 return true; | 174 return true; |
| 187 local username = jid_split(stanza.attr.to) or origin.username; | 187 local username = jid_split(stanza.attr.to) or origin.username; |
| 188 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then | 188 if not stanza.attr.to or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then |
| 189 if node and node ~= "" then | 189 if node and node ~= "" then |
| 190 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#items', node=node}); | 190 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#items', node=node}); |
| 191 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account | 191 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account |
| 192 local event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; | 192 local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false}; |
| 193 local ret = module:fire_event("account-disco-items-node", event); | 193 local ret = module:fire_event("account-disco-items-node", node_event); |
| 194 if ret ~= nil then return ret; end | 194 if ret ~= nil then return ret; end |
| 195 if event.exists then | 195 if node_event.exists then |
| 196 origin.send(reply); | 196 origin.send(reply); |
| 197 else | 197 else |
| 198 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); | 198 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Node does not exist")); |
| 199 end | 199 end |
| 200 return true; | 200 return true; |
