mod_pep_plus: Prevent nil from being added as a child on item deletion.
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Fri, 08 Jun 2018 23:03:34 +0200
changeset 8898 d00ea07de9a0
parent 8897 7273fb6af831
child 8899 739deb514140
mod_pep_plus: Prevent nil from being added as a child on item deletion.
plugins/mod_pep_plus.lua
--- a/plugins/mod_pep_plus.lua	Fri Jun 08 17:44:44 2018 +0200
+++ b/plugins/mod_pep_plus.lua	Fri Jun 08 23:03:34 2018 +0200
@@ -63,14 +63,14 @@
 local function get_broadcaster(username)
 	local user_bare = jid_join(username, host);
 	local function simple_broadcast(kind, node, jids, item)
+		local message = st.message({ from = user_bare, type = "headline" })
+			:tag("event", { xmlns = xmlns_pubsub_event })
+				:tag(kind, { node = node });
 		if item then
 			item = st.clone(item);
 			item.attr.xmlns = nil; -- Clear the pubsub namespace
+			message:add_child(item);
 		end
-		local message = st.message({ from = user_bare, type = "headline" })
-			:tag("event", { xmlns = xmlns_pubsub_event })
-				:tag(kind, { node = node })
-					:add_child(item);
 		for jid in pairs(jids) do
 			module:log("debug", "Sending notification to %s from %s: %s", jid, user_bare, tostring(item));
 			message.attr.to = jid;