mod_mamsub: Prevent nil indexing if message is added to archive of an offline user
authorKim Alvefur <zash@zash.se>
Mon, 18 May 2015 03:31:53 +0200
changeset 1752 0697fbef9134
parent 1751 985e05ac833b
child 1753 39a0a35f02bc
mod_mamsub: Prevent nil indexing if message is added to archive of an offline user
mod_mamsub/mod_mamsub.lua
--- a/mod_mamsub/mod_mamsub.lua	Mon May 18 03:27:08 2015 +0200
+++ b/mod_mamsub/mod_mamsub.lua	Mon May 18 03:31:53 2015 +0200
@@ -47,7 +47,8 @@
 end);
 
 module:hook("archive-message-added", function (event)
-	local mamsub_sessions = host_sessions[event.for_user].mamsub_sessions;
+	local user_session = host_sessions[event.for_user];
+	local mamsub_sessions = user_session and user_session.mamsub_sessions;
 	if not mamsub_sessions then return end;
 
 	local for_broadcast = st.message():tag("mamsub", { xmlns = xmlns_mamsub })