# HG changeset patch # User Kim Alvefur # Date 1530143188 -7200 # Node ID 3a095233e1782361404432a9cbe654805c45b155 # Parent cbeb1a045eb60999f8e83d4bfc8f8b192c04eb68 mod_pubsub: Handle optional item (thanks jonasw) The ‘item’ argument is optional, so it needs to handle it not being included, or util.stanza will throw an error in add_child diff -r cbeb1a045eb6 -r 3a095233e178 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Wed Jun 27 20:06:13 2018 +0200 +++ b/plugins/mod_pubsub/mod_pubsub.lua Thu Jun 28 01:46:28 2018 +0200 @@ -55,10 +55,13 @@ local message = st.message({ from = module.host, type = msg_type, id = id }) :tag("event", { xmlns = xmlns_pubsub_event }) :tag(kind, { node = node }) - :add_child(item); + + if item then + message:add_child(item); + end -- Compose a sensible textual representation of at least Atom payloads - if node_obj and node_obj.config.include_body and item.tags[1] then + if node_obj and item and node_obj.config.include_body and item.tags[1] then local payload = item.tags[1]; if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then message:reset();