diff mod_pubsub_feeds/mod_pubsub_feeds.lua @ 4282:281a864e7472

mod_pubsub_feeds: Don't skip publishing items after an existing one I encountered a feed which was backwards, such that older entries were considered first and then it would skip newer entries. This may however run into trouble if the feed contains more items than what's persisted in pubsub.
author Kim Alvefur <zash@zash.se>
date Mon, 30 Nov 2020 15:17:29 +0100
parents 27cc66bf918b
children 68bd8ae9b827
line wrap: on
line diff
--- a/mod_pubsub_feeds/mod_pubsub_feeds.lua	Tue Dec 01 22:12:16 2020 +0100
+++ b/mod_pubsub_feeds/mod_pubsub_feeds.lua	Mon Nov 30 15:17:29 2020 +0100
@@ -118,18 +118,15 @@
 				-- Sigh, no link?
 				id = feed.url .. "#" .. hmac_sha1(feed.url, tostring(entry), true) .. "@" .. dt_datetime(timestamp);
 			end
-			if items[id] then
-				-- Assume that this existing means we've added all new items
-				-- FIXME Entries updated after publishing ...
-				break;
-			end
-			local xitem = st.stanza("item", { id = id, xmlns = "http://jabber.org/protocol/pubsub" }):add_child(entry);
-			-- TODO Put data from /feed into item/source
+			if not items[id] then
+				local xitem = st.stanza("item", { id = id, xmlns = "http://jabber.org/protocol/pubsub" }):add_child(entry);
+				-- TODO Put data from /feed into item/source
 
-			--module:log("debug", "publishing to %s, id %s", node, id);
-			local ok, err = pubsub.service:publish(node, true, id, xitem);
-			if not ok then
-				module:log("error", "Publishing to node %s failed: %s", node, err);
+				--module:log("debug", "publishing to %s, id %s", node, id);
+				local ok, err = pubsub.service:publish(node, true, id, xitem);
+				if not ok then
+					module:log("error", "Publishing to node %s failed: %s", node, err);
+				end
 			end
 		end
 	end