# HG changeset patch # User Kim Alvefur # Date 1479578873 -3600 # Node ID 2f083426fe98c389de2733c27f97660b4e40a9a9 # Parent bc6e63ab2a7c90a4c8591be446938056428d9057 mod_pubsub_feeds: Use URL as ID if no id set. If that's not there either then hash stuff and call it a day diff -r bc6e63ab2a7c -r 2f083426fe98 mod_pubsub_feeds/mod_pubsub_feeds.lua --- 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