Comparison

mod_pubsub_feeds/mod_pubsub_feeds.lua @ 795:c7f507a190a0

mod_pubsub_feeds: Check if nodes exists in pubsub, make sure they get restored if not. (Thanks Maranda)
author Kim Alvefur <zash@zash.se>
date Wed, 15 Aug 2012 16:49:00 +0200
parent 794:5a8fa70faa13
child 796:9e1dab7310c0
comparison
equal deleted inserted replaced
794:5a8fa70faa13 795:c7f507a190a0
45 local config = module:get_option("feeds") or { 45 local config = module:get_option("feeds") or {
46 planet_jabber = "http://planet.jabber.org/atom.xml"; 46 planet_jabber = "http://planet.jabber.org/atom.xml";
47 prosody_blog = "http://blog.prosody.im/feed/atom.xml"; 47 prosody_blog = "http://blog.prosody.im/feed/atom.xml";
48 }; 48 };
49 refresh_interval = module:get_option_number("feed_pull_interval", 15) * 60; 49 refresh_interval = module:get_option_number("feed_pull_interval", 15) * 60;
50 local nodes = pubsub.service.get_nodes(true);
50 local new_feed_list = {}; 51 local new_feed_list = {};
51 for node, url in pairs(config) do 52 for node, url in pairs(config) do
52 if type(node) == "number" then 53 if type(node) == "number" then
53 node = url; 54 node = url;
54 end 55 end
55 new_feed_list[node] = true; 56 new_feed_list[node] = true;
56 if not feed_list[node] then 57 if not feed_list[node] then
57 feed_list[node] = { url = url; node = node; last_update = 0 }; 58 feed_list[node] = { url = url; node = node; last_update = 0 };
58 else 59 else
59 feed_list[node].url = url; 60 feed_list[node].url = url;
61 end
62 if not nodes[node] then
63 feed_list[node].last_update = 0;
60 end 64 end
61 end 65 end
62 for node in pairs(feed_list) do 66 for node in pairs(feed_list) do
63 if not new_feed_list[node] then 67 if not new_feed_list[node] then
64 feed_list[node] = nil; 68 feed_list[node] = nil;