# HG changeset patch # User Kim Alvefur # Date 1290887062 -3600 # Node ID aa0df3db4901c4a587c2f360c20f0c7f5f35c687 # Parent 653c1826739e893893a4c71f3feba5e6fce29fe7 mod_pubsub_feed: Wrap entry in a item element. diff -r 653c1826739e -r aa0df3db4901 mod_pubsub_feed/mod_pubsub_feed.lua --- a/mod_pubsub_feed/mod_pubsub_feed.lua Sat Nov 27 04:14:53 2010 +0100 +++ b/mod_pubsub_feed/mod_pubsub_feed.lua Sat Nov 27 20:44:22 2010 +0100 @@ -6,7 +6,7 @@ -- "pubsub_feed"; -- } -- feeds = { -- node -> url --- telecomix = "https://status.telecomix.org/api/statuses/public_timeline.atom"; +-- prosody_blog = "http://blog.prosody.im/feed/atom.xml"; -- } -- feed_pull_interval = 20 -- minutes @@ -16,9 +16,10 @@ end local add_task = require "util.timer".add_task; local date, time = os.date, os.time; -local dt_parse = require "util.datetime".parse; +local dt_parse, dt_datetime = require "util.datetime".parse, require "util.datetime".datetime; local http = require "net.http"; local parse_feed = require "feeds".feed_from_string; +local st = require "util.stanza"; local config = module:get_option("feeds") or { planet_jabber = "http://planet.jabber.org/atom.xml"; @@ -68,9 +69,11 @@ 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("id"); - id = id[1] or item.url.."#"..timestamp; + id = id[1] or item.url.."#"..dt_datetime(timestamp); -- Missing id, so make one up + local item = st.stanza("item", { id = id }):add_child(entry); + module:log("debug", "publishing to %s, id %s", node, id); - modules.pubsub.service:publish(node, actor, id, entry) + modules.pubsub.service:publish(node, actor, id, item) end end end);