aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-12-29 21:49:32 +0100
committerKim Alvefur <zash@zash.se>2018-12-29 21:49:32 +0100
commit7b676a12e7e29793ce582311bf6f1c446f199259 (patch)
tree498e285c672879ef0fb570aa419d07e536d58fb4
parent708dc874279d00235cb729b61f7438e753bd8008 (diff)
parent501e9d634bdbbe40cbbedb930f5479a5bd383c33 (diff)
downloadprosody-7b676a12e7e29793ce582311bf6f1c446f199259.tar.gz
prosody-7b676a12e7e29793ce582311bf6f1c446f199259.zip
Merge 0.11->trunk
-rw-r--r--spec/util_pubsub_spec.lua30
-rw-r--r--util/pubsub.lua14
2 files changed, 44 insertions, 0 deletions
diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua
index c44832f7..6386100b 100644
--- a/spec/util_pubsub_spec.lua
+++ b/spec/util_pubsub_spec.lua
@@ -375,4 +375,34 @@ describe("util.pubsub", function ()
end);
end);
end);
+
+ describe("restoring data from nodestore", function ()
+ local nodestore = {
+ data = {
+ test = {
+ name = "test";
+ config = {};
+ affiliations = {};
+ subscribers = {
+ ["someone"] = true;
+ };
+ }
+ }
+ };
+ function nodestore:users()
+ return pairs(self.data)
+ end
+ function nodestore:get(key)
+ return self.data[key];
+ end
+ local service = pubsub.new({
+ nodestore = nodestore;
+ });
+ it("subscriptions", function ()
+ local ok, ret = service:get_subscriptions(nil, true, nil)
+ assert.is_true(ok);
+ assert.same({ { node = "test", jid = "someone", subscription = true, } }, ret);
+ end);
+ end);
+
end);
diff --git a/util/pubsub.lua b/util/pubsub.lua
index fafae50a..47e526a7 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -177,6 +177,20 @@ local function new(config)
for node_name in config.nodestore:users() do
service.nodes[node_name] = load_node_from_store(service, node_name);
service.data[node_name] = config.itemstore(service.nodes[node_name].config, node_name);
+
+ for jid in pairs(service.nodes[node_name].subscribers) do
+ local normal_jid = service.config.normalize_jid(jid);
+ local subs = service.subscriptions[normal_jid];
+ if subs then
+ if not subs[jid] then
+ subs[jid] = { [node_name] = true };
+ else
+ subs[jid][node_name] = true;
+ end
+ else
+ service.subscriptions[normal_jid] = { [jid] = { [node_name] = true } };
+ end
+ end
end
end