Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.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 | 7358:d0390bc9c5d1 |
child | 8213:e1272aeef31c |
comparison
equal
deleted
inserted
replaced
8209:39f24de4f53f | 8210:352d605b1178 |
---|---|
1 local t_unpack = table.unpack or unpack; -- luacheck: ignore 113 | |
2 | |
1 local st = require "util.stanza"; | 3 local st = require "util.stanza"; |
2 local uuid_generate = require "util.uuid".generate; | 4 local uuid_generate = require "util.uuid".generate; |
3 local dataform = require"util.dataforms".new; | 5 local dataform = require"util.dataforms".new; |
4 | 6 |
5 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | 7 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; |
21 ["forbidden"] = { "auth", "forbidden" }; | 23 ["forbidden"] = { "auth", "forbidden" }; |
22 ["not-allowed"] = { "cancel", "not-allowed" }; | 24 ["not-allowed"] = { "cancel", "not-allowed" }; |
23 }; | 25 }; |
24 local function pubsub_error_reply(stanza, error) | 26 local function pubsub_error_reply(stanza, error) |
25 local e = pubsub_errors[error]; | 27 local e = pubsub_errors[error]; |
26 local reply = st.error_reply(stanza, unpack(e, 1, 3)); | 28 local reply = st.error_reply(stanza, t_unpack(e, 1, 3)); |
27 if e[4] then | 29 if e[4] then |
28 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up(); | 30 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up(); |
29 end | 31 end |
30 return reply; | 32 return reply; |
31 end | 33 end |
45 }; | 47 }; |
46 | 48 |
47 function handlers.get_items(origin, stanza, items, service) | 49 function handlers.get_items(origin, stanza, items, service) |
48 local node = items.attr.node; | 50 local node = items.attr.node; |
49 local item = items:get_child("item"); | 51 local item = items:get_child("item"); |
50 local id = item and item.attr.id; | 52 local item_id = item and item.attr.id; |
51 | 53 |
52 if not node then | 54 if not node then |
53 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 55 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
54 return true; | 56 return true; |
55 end | 57 end |
56 local ok, results = service:get_items(node, stanza.attr.from, id); | 58 local ok, results = service:get_items(node, stanza.attr.from, item_id); |
57 if not ok then | 59 if not ok then |
58 origin.send(pubsub_error_reply(stanza, results)); | 60 origin.send(pubsub_error_reply(stanza, results)); |
59 return true; | 61 return true; |
60 end | 62 end |
61 | 63 |
120 end | 122 end |
121 | 123 |
122 function handlers.set_delete(origin, stanza, delete, service) | 124 function handlers.set_delete(origin, stanza, delete, service) |
123 local node = delete.attr.node; | 125 local node = delete.attr.node; |
124 | 126 |
125 local reply, notifier; | 127 local reply; |
126 if not node then | 128 if not node then |
127 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 129 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
128 return true; | 130 return true; |
129 end | 131 end |
130 local ok, ret = service:delete(node, stanza.attr.from); | 132 local ok, ret = service:delete(node, stanza.attr.from); |