Software /
code /
prosody
Comparison
plugins/mod_mimicking.lua @ 9983:f7d11503fdce
mod_mimicking: Use new storage API
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 29 Apr 2019 02:38:55 +0200 |
parent | 9982:d09575dae242 |
child | 9984:bbabd35b30ae |
comparison
equal
deleted
inserted
replaced
9982:d09575dae242 | 9983:f7d11503fdce |
---|---|
8 | 8 |
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 datamanager = require "util.datamanager"; | |
14 local usage = require "util.prosodyctl".show_usage; | 13 local usage = require "util.prosodyctl".show_usage; |
15 local warn = require "util.prosodyctl".show_warning; | 14 local warn = require "util.prosodyctl".show_warning; |
16 local users = require "usermanager".users; | 15 local users = require "usermanager".users; |
17 | 16 |
17 local skeletons = module:open_store("skeletons"); | |
18 | |
18 module:hook("user-registered", function(user) | 19 module:hook("user-registered", function(user) |
19 datamanager.store(skeleton(user.username), user.host, "skeletons", {username = user.username}); | 20 skeletons:set(skeleton(user.username), { username = user.username }); |
20 end); | 21 end); |
21 | 22 |
22 module:hook("user-deleted", function(user) | 23 module:hook("user-deleted", function(user) |
23 datamanager.store(skeleton(user.username), user.host, "skeletons", nil); | 24 skeletons:set(skeleton(user.username), nil); |
24 end); | 25 end); |
25 | 26 |
26 module:hook("user-registering", function(user) | 27 module:hook("user-registering", function(user) |
27 if datamanager.load(skeleton(user.username), user.host, "skeletons") then | 28 if skeletons:get(skeleton(user.username)) then |
28 user.allowed = false; | 29 user.allowed = false; |
29 end | 30 end |
30 end); | 31 end); |
31 | 32 |
32 function module.command(arg) | 33 function module.command(arg) |