Changeset

5572:fd1c535dcb92

mod_pubsub_feeds: Create pubsub nodes on module load instead of later Should produce faster feedback of things being wrong.
author Kim Alvefur <zash@zash.se>
date Sun, 25 Jun 2023 16:41:50 +0200
parents 5571:ca3c2d11823c
children 5573:ed177fa5b54c
files mod_pubsub_feeds/mod_pubsub_feeds.lua
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_pubsub_feeds/mod_pubsub_feeds.lua	Sun Jun 25 16:27:55 2023 +0200
+++ b/mod_pubsub_feeds/mod_pubsub_feeds.lua	Sun Jun 25 16:41:50 2023 +0200
@@ -61,7 +61,12 @@
 		end
 		new_feed_list[node] = true;
 		if not feed_list[node] then
-			feed_list[node] = { url = url; node = node; last_update = 0 };
+			local ok, err = pubsub.service:create(node, true);
+			if ok then
+				feed_list[node] = { url = url; node = node; last_update = 0 };
+			else
+				module:log("error", "Could not create node %s: %s", node, err);
+			end
 		else
 			feed_list[node].url = url;
 		end
@@ -91,12 +96,8 @@
 	end
 	local ok, items = pubsub.service:get_items(node, true);
 	if not ok then
-		local ok, err = pubsub.service:create(node, true);
-		if not ok then
-			module:log("error", "Could not create node %s: %s", node, err);
-			return;
-		end
-		items = {};
+		module:log("error", "PubSub node %q missing: %s", node, items);
+		return
 	end
 
 	local start_from = #entries;