mod_pubsub_feeds/mod_pubsub_feeds.lua
changeset 2384 2f083426fe98
parent 2383 bc6e63ab2a7c
child 2385 a4614a329bdd
--- a/mod_pubsub_feeds/mod_pubsub_feeds.lua	Sat Nov 19 19:07:00 2016 +0100
+++ b/mod_pubsub_feeds/mod_pubsub_feeds.lua	Sat Nov 19 19:07:53 2016 +0100
@@ -96,7 +96,14 @@
 		--module:log("debug", "timestamp is %s, item.last_update is %s", tostring(timestamp), tostring(item.last_update));
 		if not timestamp or not item.last_update or timestamp > item.last_update then
 			local id = entry:get_child_text("id");
-			id = id or item.url.."#"..dt_datetime(timestamp); -- Missing id, so make one up
+			if not id then
+				local link = entry:get_child("link");
+				id = link and link.attr.href;
+			end
+			if not id then
+				-- Sigh, no link?
+				id = feed.url .. "#" .. hmac_sha1(feed.url, tostring(entry), true) .. "@" .. dt_datetime(timestamp);
+			end
 			local xitem = st.stanza("item", { id = id }):add_child(entry);
 			-- TODO Put data from /feed into item/source