Mercurial > prosody-modules
changeset 2380:2f083426fe98
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
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 19 Nov 2016 19:07:53 +0100 |
parents | bc6e63ab2a7c |
children | a4614a329bdd |
files | mod_pubsub_feeds/mod_pubsub_feeds.lua |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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