comparison mod_pubsub_feeds/mod_pubsub_feeds.lua @ 792:db27f07342d4

mod_pubsub_feeds: Use reference to mod_pubsub from module:depends
author Kim Alvefur <zash@zash.se>
date Wed, 15 Aug 2012 16:31:27 +0200
parents 82d292e4f30f
children 9fd30261b0e1
comparison
equal deleted inserted replaced
791:b9d149936764 792:db27f07342d4
13 -- feed_pull_interval = 20 -- minutes 13 -- feed_pull_interval = 20 -- minutes
14 -- 14 --
15 -- Reference 15 -- Reference
16 -- http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html 16 -- http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html
17 17
18 local modules = hosts[module.host].modules; 18 local pubsub = module:depends"pubsub";
19 module:depends"pubsub";
20 19
21 local date, time = os.date, os.time; 20 local date, time = os.date, os.time;
22 local dt_parse, dt_datetime = require "util.datetime".parse, require "util.datetime".datetime; 21 local dt_parse, dt_datetime = require "util.datetime".parse, require "util.datetime".datetime;
23 local uuid = require "util.uuid".generate; 22 local uuid = require "util.uuid".generate;
24 local hmac_sha1 = require "util.hmac".sha1; 23 local hmac_sha1 = require "util.hmac".sha1;
89 id = id or item.url.."#"..dt_datetime(timestamp); -- Missing id, so make one up 88 id = id or item.url.."#"..dt_datetime(timestamp); -- Missing id, so make one up
90 local xitem = st.stanza("item", { id = id }):add_child(entry); 89 local xitem = st.stanza("item", { id = id }):add_child(entry);
91 -- TODO Put data from /feed into item/source 90 -- TODO Put data from /feed into item/source
92 91
93 --module:log("debug", "publishing to %s, id %s", node, id); 92 --module:log("debug", "publishing to %s, id %s", node, id);
94 local ok, err = modules.pubsub.service:publish(node, true, id, xitem); 93 local ok, err = pubsub.service:publish(node, true, id, xitem);
95 if not ok then 94 if not ok then
96 if err == "item-not-found" then -- try again 95 if err == "item-not-found" then -- try again
97 --module:log("debug", "got item-not-found, creating %s and trying again", node); 96 --module:log("debug", "got item-not-found, creating %s and trying again", node);
98 local ok, err = modules.pubsub.service:create(node, true); 97 local ok, err = pubsub.service:create(node, true);
99 if not ok then 98 if not ok then
100 module:log("error", "could not create node %s: %s", node, err); 99 module:log("error", "could not create node %s: %s", node, err);
101 return; 100 return;
102 end 101 end
103 local ok, err = modules.pubsub.service:publish(node, true, id, xitem); 102 local ok, err = pubsub.service:publish(node, true, id, xitem);
104 if not ok then 103 if not ok then
105 module:log("error", "could not create or publish node %s: %s", node, err); 104 module:log("error", "could not create or publish node %s: %s", node, err);
106 return 105 return
107 end 106 end
108 else 107 else