comparison 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
comparison
equal deleted inserted replaced
4281:3c80e46e26f2 4282:281a864e7472
116 end 116 end
117 if not id then 117 if not id then
118 -- Sigh, no link? 118 -- Sigh, no link?
119 id = feed.url .. "#" .. hmac_sha1(feed.url, tostring(entry), true) .. "@" .. dt_datetime(timestamp); 119 id = feed.url .. "#" .. hmac_sha1(feed.url, tostring(entry), true) .. "@" .. dt_datetime(timestamp);
120 end 120 end
121 if items[id] then 121 if not items[id] then
122 -- Assume that this existing means we've added all new items 122 local xitem = st.stanza("item", { id = id, xmlns = "http://jabber.org/protocol/pubsub" }):add_child(entry);
123 -- FIXME Entries updated after publishing ... 123 -- TODO Put data from /feed into item/source
124 break; 124
125 end 125 --module:log("debug", "publishing to %s, id %s", node, id);
126 local xitem = st.stanza("item", { id = id, xmlns = "http://jabber.org/protocol/pubsub" }):add_child(entry); 126 local ok, err = pubsub.service:publish(node, true, id, xitem);
127 -- TODO Put data from /feed into item/source 127 if not ok then
128 128 module:log("error", "Publishing to node %s failed: %s", node, err);
129 --module:log("debug", "publishing to %s, id %s", node, id); 129 end
130 local ok, err = pubsub.service:publish(node, true, id, xitem);
131 if not ok then
132 module:log("error", "Publishing to node %s failed: %s", node, err);
133 end 130 end
134 end 131 end
135 end 132 end
136 133
137 if item.lease_expires and item.lease_expires > time() then 134 if item.lease_expires and item.lease_expires > time() then