From 7b30d1b18a4a53fecada187fec6228440ebbac5b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 18 Oct 2017 07:46:44 +0200 Subject: mod_pubsub: Move dispatch function into pubsub.lib --- plugins/mod_pubsub/mod_pubsub.lua | 13 +------------ plugins/mod_pubsub/pubsub.lib.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index b1418ff9..eccb82d0 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -24,18 +24,7 @@ module:add_identity("pubsub", "service", pubsub_disco_name); 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 --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 829c4833..5d173e4f 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -53,6 +53,20 @@ local node_config_form = dataform { }; }; +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"); -- cgit v1.2.3