From 0e1bf3c061a36edaea119d859aacb9764325c5bf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 16 May 2021 16:02:00 +0200 Subject: util.pubsub: Fix traceback if node data not initialized This should not be possible, but a traceback indicating node_data being nil here was reported by Ron in the chat. --- util/pubsub.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/pubsub.lua b/util/pubsub.lua index 1674b9a7..7ccc817f 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -555,6 +555,10 @@ function service:publish(node, actor, id, item, requested_config) --> ok, err return nil, "invalid-item"; end local node_data = self.data[node]; + if not node_data then + -- FIXME how is this possible? #1657 + return nil, "internal-server-error"; + end local ok = node_data:set(id, item); if not ok then return nil, "internal-server-error"; -- cgit v1.2.3 From 0c6f17043f100150629d9b4c9c27a3489958f67c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 16 May 2021 16:14:23 +0200 Subject: mod_pep: Remove obsolete node restoration code (now done by util.pubsub) Originally added in 202b9951b037 but util.pubsub gained a better method in 6c2c2fc4b8dd since then, which mod_pep uses since 9194431b6447 which should have deleted this. All these :create calls would have failed with a 'conflict' error, since the nodes had already been created. This was never noticed because of missing error handling. Also note that this code did not restore node configuration. --- plugins/mod_pep.lua | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index d94cab40..4dc9ecbc 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -207,18 +207,6 @@ function get_pep_service(username) check_node_config = check_node_config; }); - 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; -- cgit v1.2.3