Software /
code /
prosody-modules
Changeset
5578:b9821e9a21a2
mod_pubsub_feeds: Pass feed data as argument instead of storing on object
Feeds can be quite large, why were we keeping them after parsing???
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 25 Jun 2023 20:15:44 +0200 |
parents | 5577:e7792188540a |
children | 5579:bc292c84f56c |
files | mod_pubsub_feeds/mod_pubsub_feeds.lua |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_pubsub_feeds/mod_pubsub_feeds.lua Sun Jun 25 19:58:45 2023 +0200 +++ b/mod_pubsub_feeds/mod_pubsub_feeds.lua Sun Jun 25 20:15:44 2023 +0200 @@ -68,13 +68,13 @@ end end -function update_entry(item) +function update_entry(item, data) local node = item.node; - module:log("debug", "parsing %d bytes of data in node %s", #item.data or 0, node) - local feed, err = parse_feed(item.data); + module:log("debug", "parsing %d bytes of data in node %s", #data or 0, node) + local feed, err = parse_feed(data); if not feed then module:log("error", "Could not parse feed %q: %s", item.url, err); - module:log("debug", "Feed data:\n%s\n.", item.data); + module:log("debug", "Feed data:\n%s\n.", data); return; end local entries = {}; @@ -152,13 +152,12 @@ function fetch(item, callback) -- HTTP Pull local headers = { }; - if item.data and item.etag then + if item.etag then headers["If-None-Match"] = item.etag; end http.request(item.url, { headers = headers }, function(data, code, resp) if code == 200 then - item.data = data; - if callback then callback(item) end + if callback then callback(item, data) end if resp.headers then item.etag = resp.headers.etag end @@ -270,8 +269,7 @@ end module:log("debug", "Valid signature"); end - feed.data = body; - update_entry(feed); + update_entry(feed, body); return 202; end return 400;