aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-02-27 19:42:51 +0100
committerKim Alvefur <zash@zash.se>2020-02-27 19:42:51 +0100
commit85ce63a7a7d2e83dcf5fdaa9ddf998bb7d21b351 (patch)
treeb6fdc8000ddcb2a0a7f0ac313d3efe882223643d /plugins
parentaa740e0573a22006f779f17c3176ad934f4f3dca (diff)
downloadprosody-85ce63a7a7d2e83dcf5fdaa9ddf998bb7d21b351.tar.gz
prosody-85ce63a7a7d2e83dcf5fdaa9ddf998bb7d21b351.zip
mod_muc_mam: Fix traceback saving message from non-occupant (fixes #1497)
Caused by a plugin sending a message from the room itself.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_muc_mam.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/mod_muc_mam.lua b/plugins/mod_muc_mam.lua
index 2ce5e1b5..f7ea3136 100644
--- a/plugins/mod_muc_mam.lua
+++ b/plugins/mod_muc_mam.lua
@@ -335,11 +335,14 @@ local function save_to_history(self, stanza)
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