Software /
code /
prosody
Comparison
plugins/mod_pep_plus.lua @ 8214:da8bc600902a
mod_pep_plus: Fix all of the warnings [luacheck]
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 15 Apr 2017 01:26:19 +0100 |
parent | 6449:24cd03cd1847 |
child | 8215:835bb32c36b4 |
comparison
equal
deleted
inserted
replaced
8213:e1272aeef31c | 8214:da8bc600902a |
---|---|
10 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; | 10 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; |
11 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; | 11 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; |
12 | 12 |
13 local lib_pubsub = module:require "pubsub"; | 13 local lib_pubsub = module:require "pubsub"; |
14 local handlers = lib_pubsub.handlers; | 14 local handlers = lib_pubsub.handlers; |
15 local pubsub_error_reply = lib_pubsub.pubsub_error_reply; | |
16 | 15 |
17 local empty_set = set_new(); | 16 local empty_set = set_new(); |
18 | 17 |
19 local services = {}; | 18 local services = {}; |
20 local recipients = {}; | 19 local recipients = {}; |
177 return service; | 176 return service; |
178 end | 177 end |
179 | 178 |
180 function handle_pubsub_iq(event) | 179 function handle_pubsub_iq(event) |
181 local origin, stanza = event.origin, event.stanza; | 180 local origin, stanza = event.origin, event.stanza; |
182 local pubsub = stanza.tags[1]; | 181 local pubsub_tag = stanza.tags[1]; |
183 local action = pubsub.tags[1]; | 182 local action = pubsub_tag.tags[1]; |
184 if not action then | 183 if not action then |
185 return origin.send(st.error_reply(stanza, "cancel", "bad-request")); | 184 return origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
186 end | 185 end |
187 local service_name = stanza.attr.to or origin.username.."@"..origin.host | 186 local service_name = stanza.attr.to or origin.username.."@"..origin.host |
188 local service = get_pep_service(service_name); | 187 local service = get_pep_service(service_name); |
223 end | 222 end |
224 | 223 |
225 local function resend_last_item(jid, node, service) | 224 local function resend_last_item(jid, node, service) |
226 local ok, items = service:get_items(node, jid); | 225 local ok, items = service:get_items(node, jid); |
227 if not ok then return; end | 226 if not ok then return; end |
228 for i, id in ipairs(items) do | 227 for _, id in ipairs(items) do |
229 service.config.broadcaster("items", node, { [jid] = true }, items[id]); | 228 service.config.broadcaster("items", node, { [jid] = true }, items[id]); |
230 end | 229 end |
231 end | 230 end |
232 | 231 |
233 local function update_subscriptions(recipient, service_name, nodes) | 232 local function update_subscriptions(recipient, service_name, nodes) |
269 -- inbound presence to bare JID recieved | 268 -- inbound presence to bare JID recieved |
270 local origin, stanza = event.origin, event.stanza; | 269 local origin, stanza = event.origin, event.stanza; |
271 local user = stanza.attr.to or (origin.username..'@'..origin.host); | 270 local user = stanza.attr.to or (origin.username..'@'..origin.host); |
272 local t = stanza.attr.type; | 271 local t = stanza.attr.type; |
273 local self = not stanza.attr.to; | 272 local self = not stanza.attr.to; |
274 local service = get_pep_service(user); | |
275 | 273 |
276 if not t then -- available presence | 274 if not t then -- available presence |
277 if self or subscription_presence(user, stanza.attr.from) then | 275 if self or subscription_presence(user, stanza.attr.from) then |
278 local recipient = stanza.attr.from; | 276 local recipient = stanza.attr.from; |
279 local current = recipients[user] and recipients[user][recipient]; | 277 local current = recipients[user] and recipients[user][recipient]; |