# HG changeset patch # User Kim Alvefur # Date 1508305604 -7200 # Node ID 036e46d12b78a15dccefde9348561c57deabc9c5 # Parent 2abbb01cd756e302fef1fc27eb7cdd57bf3d4be5 mod_pubsub: Move dispatch function into pubsub.lib diff -r 2abbb01cd756 -r 036e46d12b78 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Tue Oct 17 05:47:06 2017 +0200 +++ b/plugins/mod_pubsub/mod_pubsub.lua Wed Oct 18 07:46:44 2017 +0200 @@ -24,18 +24,7 @@ module:add_feature("http://jabber.org/protocol/pubsub"); function handle_pubsub_iq(event) - local origin, stanza = event.origin, event.stanza; - local pubsub_tag = stanza.tags[1]; - local action = pubsub_tag.tags[1]; - if not action then - origin.send(st.error_reply(stanza, "cancel", "bad-request")); - return true; - end - local handler = handlers[stanza.attr.type.."_"..action.name]; - if handler then - handler(origin, stanza, action, service); - return true; - end + return lib_pubsub.handle_pubsub_iq(event, service); end local function simple_itemstore(config, node) diff -r 2abbb01cd756 -r 036e46d12b78 plugins/mod_pubsub/pubsub.lib.lua --- a/plugins/mod_pubsub/pubsub.lib.lua Tue Oct 17 05:47:06 2017 +0200 +++ b/plugins/mod_pubsub/pubsub.lib.lua Wed Oct 18 07:46:44 2017 +0200 @@ -53,6 +53,20 @@ }; }; +function _M.handle_pubsub_iq(event, service) + local origin, stanza = event.origin, event.stanza; + local pubsub_tag = stanza.tags[1]; + local action = pubsub_tag.tags[1]; + if not action then + return origin.send(st.error_reply(stanza, "cancel", "bad-request")); + end + local handler = handlers[stanza.attr.type.."_"..action.name]; + if handler then + handler(origin, stanza, action, service); + return true; + end +end + function handlers.get_items(origin, stanza, items, service) local node = items.attr.node; local item = items:get_child("item");