Comparison

plugins/mod_mimicking.lua @ 9984:bbabd35b30ae

mod_mimicking: Update command to work with current code
author Kim Alvefur <zash@zash.se>
date Mon, 29 Apr 2019 02:40:14 +0200
parent 9983:f7d11503fdce
child 9985:46c038969eb3
comparison
equal deleted inserted replaced
9983:f7d11503fdce 9984:bbabd35b30ae
9 local encodings = require "util.encodings"; 9 local encodings = require "util.encodings";
10 assert(encodings.confusable, "This module requires that Prosody be built with ICU"); 10 assert(encodings.confusable, "This module requires that Prosody be built with ICU");
11 local skeleton = encodings.confusable.skeleton; 11 local skeleton = encodings.confusable.skeleton;
12 12
13 local usage = require "util.prosodyctl".show_usage; 13 local usage = require "util.prosodyctl".show_usage;
14 local warn = require "util.prosodyctl".show_warning; 14 local usermanager = require "core.usermanager";
15 local users = require "usermanager".users; 15 local storagemanager = require "core.storagemanager";
16 16
17 local skeletons = module:open_store("skeletons"); 17 local skeletons
18 function module.load()
19 if module.host ~= "*" then
20 skeletons = module:open_store("skeletons");
21 end
22 end
18 23
19 module:hook("user-registered", function(user) 24 module:hook("user-registered", function(user)
20 skeletons:set(skeleton(user.username), { username = user.username }); 25 skeletons:set(skeleton(user.username), { username = user.username });
21 end); 26 end);
22 27
40 45
41 local host_session = prosody.hosts[host]; 46 local host_session = prosody.hosts[host];
42 if not host_session then 47 if not host_session then
43 return "No such host"; 48 return "No such host";
44 end 49 end
45 local provider = host_session.users; 50
46 if not(provider) or provider.name == "null" then
47 usermanager.initialize_host(host);
48 end
49 storagemanager.initialize_host(host); 51 storagemanager.initialize_host(host);
52 usermanager.initialize_host(host);
50 53
51 for user in users(host) do 54 skeletons = storagemanager.open(host, "skeletons");
52 datamanager.store(skeleton(user), host, "skeletons", {username = user}); 55
56 for user in usermanager.users(host) do
57 skeletons:set(skeleton(user), { username = user });
53 end 58 end
54 end 59 end