aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-06-28 01:46:28 +0200
committerKim Alvefur <zash@zash.se>2018-06-28 01:46:28 +0200
commitd591424f1d7c5a7ddadaad00dea1703bc339ecfc (patch)
treeebeaf4b642264a35c3658465c034274fc42098aa /plugins/mod_pubsub
parent8714ac8f2ae1f4f039b6a25b7a3ef38e1e6d69f5 (diff)
downloadprosody-d591424f1d7c5a7ddadaad00dea1703bc339ecfc.tar.gz
prosody-d591424f1d7c5a7ddadaad00dea1703bc339ecfc.zip
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
Diffstat (limited to 'plugins/mod_pubsub')
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index 707f2f8e..82c787aa 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -55,10 +55,13 @@ function simple_broadcast(kind, node, jids, item, actor, node_obj)
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();