Changeset

2293:144b74caa5ef

mod_mam: Check that user exists (#731)
author Kim Alvefur <zash@zash.se>
date Mon, 29 Aug 2016 10:51:08 +0200
parents 2292:54f44365a378
children 2294:4915b8223b07
files mod_mam/mod_mam.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_mam/mod_mam.lua	Mon Aug 29 01:06:42 2016 +0200
+++ b/mod_mam/mod_mam.lua	Mon Aug 29 10:51:08 2016 +0200
@@ -7,6 +7,7 @@
 local xmlns_delay   = "urn:xmpp:delay";
 local xmlns_forward = "urn:xmpp:forward:0";
 
+local um = require "core.usermanager";
 local st = require "util.stanza";
 local rsm = module:require "rsm";
 local get_prefs = module:require"mamprefs".get;
@@ -206,6 +207,9 @@
 
 local function shall_store(user, who)
 	-- TODO Cache this?
+	if not um.user_exists(user, host) then
+		return false;
+	end
 	local prefs = get_prefs(user);
 	local rule = prefs[who];
 	module:log("debug", "%s's rule for %s is %s", user, who, tostring(rule));
@@ -295,7 +299,6 @@
 	cleanup = {};
 
 	pcall(function ()
-		local um = require "core.usermanager";
 		for user in um.users(module.host) do
 			cleanup[user] = true;
 		end