Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 8210:352d605b1178
mod_pubsub: Fix a few warnings [luacheck]
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 14 Apr 2017 22:45:59 +0100 |
parent | 7984:ae3c5abb3336 |
child | 8213:e1272aeef31c |
comparison
equal
deleted
inserted
replaced
8209:39f24de4f53f | 8210:352d605b1178 |
---|---|
14 | 14 |
15 local service; | 15 local service; |
16 | 16 |
17 local lib_pubsub = module:require "pubsub"; | 17 local lib_pubsub = module:require "pubsub"; |
18 local handlers = lib_pubsub.handlers; | 18 local handlers = lib_pubsub.handlers; |
19 local pubsub_error_reply = lib_pubsub.pubsub_error_reply; | |
20 | 19 |
21 module:depends("disco"); | 20 module:depends("disco"); |
22 module:add_identity("pubsub", "service", pubsub_disco_name); | 21 module:add_identity("pubsub", "service", pubsub_disco_name); |
23 module:add_feature("http://jabber.org/protocol/pubsub"); | 22 module:add_feature("http://jabber.org/protocol/pubsub"); |
24 | 23 |
25 function handle_pubsub_iq(event) | 24 function handle_pubsub_iq(event) |
26 local origin, stanza = event.origin, event.stanza; | 25 local origin, stanza = event.origin, event.stanza; |
27 local pubsub = stanza.tags[1]; | 26 local pubsub_tag = stanza.tags[1]; |
28 local action = pubsub.tags[1]; | 27 local action = pubsub_tag.tags[1]; |
29 if not action then | 28 if not action then |
30 origin.send(st.error_reply(stanza, "cancel", "bad-request")); | 29 origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
31 return true; | 30 return true; |
32 end | 31 end |
33 local handler = handlers[stanza.attr.type.."_"..action.name]; | 32 local handler = handlers[stanza.attr.type.."_"..action.name]; |
88 end | 87 end |
89 end | 88 end |
90 end | 89 end |
91 | 90 |
92 module:hook("host-disco-info-node", function (event) | 91 module:hook("host-disco-info-node", function (event) |
93 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node; | 92 local stanza, reply, node = event.stanza, event.reply, event.node; |
94 local ok, ret = service:get_nodes(stanza.attr.from); | 93 local ok, ret = service:get_nodes(stanza.attr.from); |
95 if not ok or not ret[node] then | 94 if not ok or not ret[node] then |
96 return; | 95 return; |
97 end | 96 end |
98 event.exists = true; | 97 event.exists = true; |
99 reply:tag("identity", { category = "pubsub", type = "leaf" }); | 98 reply:tag("identity", { category = "pubsub", type = "leaf" }); |
100 end); | 99 end); |
101 | 100 |
102 module:hook("host-disco-items-node", function (event) | 101 module:hook("host-disco-items-node", function (event) |
103 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node; | 102 local stanza, reply, node = event.stanza, event.reply, event.node; |
104 local ok, ret = service:get_items(node, stanza.attr.from); | 103 local ok, ret = service:get_items(node, stanza.attr.from); |
105 if not ok then | 104 if not ok then |
106 return; | 105 return; |
107 end | 106 end |
108 | 107 |
112 event.exists = true; | 111 event.exists = true; |
113 end); | 112 end); |
114 | 113 |
115 | 114 |
116 module:hook("host-disco-items", function (event) | 115 module:hook("host-disco-items", function (event) |
117 local stanza, origin, reply = event.stanza, event.origin, event.reply; | 116 local stanza, reply = event.stanza, event.reply; |
118 local ok, ret = service:get_nodes(event.stanza.attr.from); | 117 local ok, ret = service:get_nodes(stanza.attr.from); |
119 if not ok then | 118 if not ok then |
120 return; | 119 return; |
121 end | 120 end |
122 for node, node_obj in pairs(ret) do | 121 for node, node_obj in pairs(ret) do |
123 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up(); | 122 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up(); |