Changeset

10670:5376f882cf82 0.11

mod_muc_mam: Fix traceback saving message from non-occupant (fixes #1497) Caused by a plugin sending a message from the room itself.
author Kim Alvefur <zash@zash.se>
date Thu, 27 Feb 2020 19:42:51 +0100
parents 10665:69acda92d5a9
children 10671:5e1384298e97 10672:657e61531b33
files plugins/mod_muc_mam.lua
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_muc_mam.lua	Mon Feb 24 23:16:08 2020 +0100
+++ b/plugins/mod_muc_mam.lua	Thu Feb 27 19:42:51 2020 +0100
@@ -335,11 +335,14 @@
 	if stanza.name == "message" and self:get_whois() == "anyone" then
 		stored_stanza = st.clone(stanza);
 		stored_stanza.attr.to = nil;
-		local actor = jid_bare(self._occupants[stanza.attr.from].jid);
-		local affiliation = self:get_affiliation(actor) or "none";
-		local role = self:get_role(actor) or self:get_default_role(affiliation);
-		stored_stanza:add_direct_child(st.stanza("x", { xmlns = xmlns_muc_user })
-			:tag("item", { affiliation = affiliation; role = role; jid = actor }));
+		local occupant = self._occupants[stanza.attr.from];
+		if occupant then
+			local actor = jid_bare(occupant.jid);
+			local affiliation = self:get_affiliation(actor) or "none";
+			local role = self:get_role(actor) or self:get_default_role(affiliation);
+			stored_stanza:add_direct_child(st.stanza("x", { xmlns = xmlns_muc_user })
+				:tag("item", { affiliation = affiliation; role = role; jid = actor }));
+		end
 	end
 
 	-- Policy check