aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-08 23:59:13 +0200
committerKim Alvefur <zash@zash.se>2017-10-08 23:59:13 +0200
commit3706f646ee19b2f4c31044506e323e4967054157 (patch)
tree58e3332fbf4107c395d331ed0fd967c74807565d /plugins
parenta744026171cafc0bcbda562c4923bc1d75109522 (diff)
downloadprosody-3706f646ee19b2f4c31044506e323e4967054157.tar.gz
prosody-3706f646ee19b2f4c31044506e323e4967054157.zip
mod_pep_plus: Keep track of nodes, and restore them when later
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_pep_plus.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/mod_pep_plus.lua b/plugins/mod_pep_plus.lua
index c848221b..52f6b66d 100644
--- a/plugins/mod_pep_plus.lua
+++ b/plugins/mod_pep_plus.lua
@@ -22,6 +22,9 @@ local hash_map = {};
local host = module.host;
+local known_nodes_map = module:open_store("pep", "map");
+local known_nodes = module:open_store("pep");
+
function module.save()
return { services = services };
end
@@ -40,6 +43,7 @@ end
local function simple_itemstore(username)
return function (config, node)
module:log("debug", "new simple_itemstore(%q, %q)", username, node);
+ known_nodes_map:set(username, node, true);
local archive = module:open_store("pep_"..node, "archive");
return lib_pubsub.simple_itemstore(archive, config, username, node, false);
end
@@ -186,6 +190,18 @@ function get_pep_service(username)
normalize_jid = jid_bare;
});
+ local nodes, err = known_nodes:get(username);
+ if nodes then
+ module:log("debug", "Restoring nodes for user %s", username);
+ for node in pairs(nodes) do
+ module:log("debug", "Restoring node %q", node);
+ service:create(node, true);
+ end
+ elseif err then
+ module:log("error", "Could not restore nodes for %s: %s", username, err);
+ else
+ module:log("debug", "No known nodes");
+ end
services[username] = service;
module:add_item("pep-service", { service = service, jid = user_bare });
return service;