Comparison

mod_mam/mod_mam.lua @ 2293:144b74caa5ef

mod_mam: Check that user exists (#731)
author Kim Alvefur <zash@zash.se>
date Mon, 29 Aug 2016 10:51:08 +0200
parent 2270:9c99200afd17
child 2505:1398f3f76c0f
comparison
equal deleted inserted replaced
2292:54f44365a378 2293:144b74caa5ef
5 5
6 local xmlns_mam = "urn:xmpp:mam:0"; 6 local xmlns_mam = "urn:xmpp:mam:0";
7 local xmlns_delay = "urn:xmpp:delay"; 7 local xmlns_delay = "urn:xmpp:delay";
8 local xmlns_forward = "urn:xmpp:forward:0"; 8 local xmlns_forward = "urn:xmpp:forward:0";
9 9
10 local um = require "core.usermanager";
10 local st = require "util.stanza"; 11 local st = require "util.stanza";
11 local rsm = module:require "rsm"; 12 local rsm = module:require "rsm";
12 local get_prefs = module:require"mamprefs".get; 13 local get_prefs = module:require"mamprefs".get;
13 local set_prefs = module:require"mamprefs".set; 14 local set_prefs = module:require"mamprefs".set;
14 local prefs_to_stanza = module:require"mamprefsxml".tostanza; 15 local prefs_to_stanza = module:require"mamprefsxml".tostanza;
204 return roster[who]; 205 return roster[who];
205 end 206 end
206 207
207 local function shall_store(user, who) 208 local function shall_store(user, who)
208 -- TODO Cache this? 209 -- TODO Cache this?
210 if not um.user_exists(user, host) then
211 return false;
212 end
209 local prefs = get_prefs(user); 213 local prefs = get_prefs(user);
210 local rule = prefs[who]; 214 local rule = prefs[who];
211 module:log("debug", "%s's rule for %s is %s", user, who, tostring(rule)); 215 module:log("debug", "%s's rule for %s is %s", user, who, tostring(rule));
212 if rule ~= nil then 216 if rule ~= nil then
213 return rule; 217 return rule;
293 end 297 end
294 298
295 cleanup = {}; 299 cleanup = {};
296 300
297 pcall(function () 301 pcall(function ()
298 local um = require "core.usermanager";
299 for user in um.users(module.host) do 302 for user in um.users(module.host) do
300 cleanup[user] = true; 303 cleanup[user] = true;
301 end 304 end
302 end); 305 end);
303 306