Diff

mod_pubsub_feed/mod_pubsub_feed.lua @ 461:bbea8081c865

Revert various changes accidentally included in previous commit
author Kim Alvefur <zash@zash.se>
date Sat, 29 Oct 2011 13:34:15 +0200
parent 455:52f2188ec47d
child 475:db5702bb9e41
line wrap: on
line diff
--- a/mod_pubsub_feed/mod_pubsub_feed.lua	Mon Oct 24 00:20:51 2011 +0000
+++ b/mod_pubsub_feed/mod_pubsub_feed.lua	Sat Oct 29 13:34:15 2011 +0200
@@ -38,33 +38,19 @@
 local urldecode  = http.urldecode;
 local urlencode  = http.urlencode;
 
-local feed_list = {};
-local refresh_interval;
-
--- Dynamicaly reloadable config.
-local function update_config()
 local config = module:get_option("feeds") or {
 	planet_jabber = "http://planet.jabber.org/atom.xml";
 	prosody_blog = "http://blog.prosody.im/feed/atom.xml";
 };
-	refresh_interval = module:get_option_number("feed_pull_interval", 15) * 60;
-	local new_feed_list;
+local refresh_interval = module:get_option_number("feed_pull_interval", 15) * 60;
+local use_pubsubhubub = module:get_option_boolean("use_pubsubhubub", true); -- HTTP by default or not?
+local httphost = module:get_option_string("pubsubhubub_httphost", module.host); -- If module.host IN A doesn't point to this server, use this to override.
+local feed_list = { }
 for node, url in pairs(config) do
-		local new_feed_list[node] = true;
-		if not feed_list[node] then
 	feed_list[node] = { url = url; node = node; last_update = 0 };
-		else
-			feed_list[node].url = url;
 end
-	end
-	for node in pairs(feed_list) do
-		if not new_feed_list[node] then
-			feed_list[node] = nil;
-		end
-	end
-end
-update_config();
-module:hook("config-reloaded", update_config);
+-- TODO module:hook("config-reloaded", above loop);
+-- Also, keeping it somewhere persistent in order to avoid duplicated publishes?
 
 -- Used to kill the timer
 local module_unloaded = false;
@@ -72,13 +58,6 @@
 	module_unloaded = true;
 end
 
--- Config stuff that can't be reloaded, since it would need to re-bind HTTP stuff.
-
--- If module.host IN A doesn't point to this server, use this to override.
-local httphost = module:get_option_string("pubsubhubub_httphost", module.host);
--- HTTP by default or not?
-local use_pubsubhubub = module:get_option_boolean("use_pubsubhubub", true);
-
 -- Thanks to Maranda for this
 local port, base, ssl = 5280, "callback", false;
 local ports = module:get_option("feeds_ports") or { port = port, base = base, ssl = ssl };
@@ -190,13 +169,12 @@
 end
 
 function refresh_feeds()
-	local now = time();
 	if module_unloaded then return end
 	--module:log("debug", "Refreshing feeds");
 	for node, item in pairs(feed_list) do
 		--FIXME Don't fetch feeds which have a subscription
 		-- Otoho, what if the subscription expires or breaks?
-		if item.last_update + refresh_interval < now then 
+		if item.last_update + refresh_interval < time() then 
 			module:log("debug", "checking %s", item.node);
 			fetch(item, update_entry);
 		end