Mercurial > prosody-modules
comparison mod_pubsub_feeds/mod_pubsub_feeds.lua @ 1343:7dbde05b48a9
all the things: Remove trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Tue, 11 Mar 2014 18:44:01 +0100 |
parents | b21236b6b8d8 |
children | 7b53cfc6ba8d |
comparison
equal
deleted
inserted
replaced
1342:0ae065453dc9 | 1343:7dbde05b48a9 |
---|---|
110 module:log("error", "publishing %s failed: %s", node, err); | 110 module:log("error", "publishing %s failed: %s", node, err); |
111 end | 111 end |
112 end | 112 end |
113 end | 113 end |
114 end | 114 end |
115 | 115 |
116 if use_pubsubhubub and not item.subscription then | 116 if use_pubsubhubub and not item.subscription then |
117 --module:log("debug", "check if %s has a hub", item.node); | 117 --module:log("debug", "check if %s has a hub", item.node); |
118 local hub = feed.links and feed.links.hub; | 118 local hub = feed.links and feed.links.hub; |
119 if hub then | 119 if hub then |
120 item.hub = hub; | 120 item.hub = hub; |
127 function fetch(item, callback) -- HTTP Pull | 127 function fetch(item, callback) -- HTTP Pull |
128 local headers = { }; | 128 local headers = { }; |
129 if item.data and item.last_update then | 129 if item.data and item.last_update then |
130 headers["If-Modified-Since"] = date("!%a, %d %b %Y %H:%M:%S %Z", item.last_update); | 130 headers["If-Modified-Since"] = date("!%a, %d %b %Y %H:%M:%S %Z", item.last_update); |
131 end | 131 end |
132 http.request(item.url, { headers = headers }, function(data, code) | 132 http.request(item.url, { headers = headers }, function(data, code) |
133 if code == 200 then | 133 if code == 200 then |
134 item.data = data; | 134 item.data = data; |
135 if callback then callback(item) end | 135 if callback then callback(item) end |
136 item.last_update = time(); | 136 item.last_update = time(); |
137 elseif code == 304 then | 137 elseif code == 304 then |
144 local now = time(); | 144 local now = time(); |
145 --module:log("debug", "Refreshing feeds"); | 145 --module:log("debug", "Refreshing feeds"); |
146 for node, item in pairs(feed_list) do | 146 for node, item in pairs(feed_list) do |
147 --FIXME Don't fetch feeds which have a subscription | 147 --FIXME Don't fetch feeds which have a subscription |
148 -- Otoho, what if the subscription expires or breaks? | 148 -- Otoho, what if the subscription expires or breaks? |
149 if force or item.last_update + refresh_interval < now then | 149 if force or item.last_update + refresh_interval < now then |
150 --module:log("debug", "checking %s", item.node); | 150 --module:log("debug", "checking %s", item.node); |
151 fetch(item, update_entry); | 151 fetch(item, update_entry); |
152 end | 152 end |
153 end | 153 end |
154 return refresh_interval; | 154 return refresh_interval; |
155 end | 155 end |
156 | 156 |
157 local function format_url(node) | 157 local function format_url(node) |
158 return module:http_url(nil, "/callback") .. "?node=" .. urlencode(node); | 158 return module:http_url(nil, "/callback") .. "?node=" .. urlencode(node); |
159 end | 159 end |
160 | 160 |
161 function subscribe(feed, want) | 161 function subscribe(feed, want) |
162 want = want or "subscribe"; | 162 want = want or "subscribe"; |
163 feed.token = uuid(); | 163 feed.token = uuid(); |
164 feed.secret = feed.secret or uuid(); | 164 feed.secret = feed.secret or uuid(); |