changeset 1748:0697fbef9134

mod_mamsub: Prevent nil indexing if message is added to archive of an offline user
author Kim Alvefur <zash@zash.se>
date Mon, 18 May 2015 03:31:53 +0200
parents 985e05ac833b
children 39a0a35f02bc
files mod_mamsub/mod_mamsub.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 })