Monday, November 08, 2010 at 12:00 AM.
river2Suite.renewSubscriptions
on renewSubscriptions (flSubscribeAll = false) { <<Changes <<9/17/09; 7:46:44 AM by DW <<Factored body of loop into renewOneSubscription to make testing much easier. <<9/7/09; 11:56:03 AM by DW <<Change in policy. If a cloud asks for http-post to request notification, then we ask for notification via http-post. This is a heuristic. Figuring if it doesn't speak XML-RPC on one side, it might not speak it on the other. (There's an app coming online that behaves this way. Early days in rssCloud.) <<8/25/09; 1:29:46 PM by DW <<Move the check for http-post inside an "else" -- to work around an (apparent) problem in the "with" statement? Weird. <<8/16/09; 9:37:30 AM by DW <<Minor tweaks to logging of renewal errors. <<8/16/09; 9:26:18 AM by DW <<Count and log renewal errors. <<8/15/09; 7:28:30 PM by DW <<Instead of hard-coding the renew at 24 hours, use the feed-level preference. <<8/10/09; 2:55:21 PM by DW <<Improved logging for "Please notify" events. <<7/25/09; 10:33:45 AM by DW <<Increment stats.ctCloudRenew. <<7/21/09; 7:48:22 PM by DW <<Add support for subscribing via REST, in addition to XML-RPC. <<7/19/09; 11:39:35 AM by DW <<Save the last cloud renew error string. <<7/17/09; 11:06:25 AM by DW <<Cribbed from xml.aggregator.updateSubscriptions. <<12/27/01; 5:55:13 PM by PBS <<If this is Frontier, check the firewall pref at adrdata^.prefs.flBehindFirewall since user.radio is not defined. <<12/9/01; 10:41:43 AM by DW <<Respect user.radio.prefs.flBehindFirewall. <<People behind firewalls cannot receive notifications. <<No point requesting them. <<1/7/01; 12:36:24 PM by DW <<Add support for HTTP-POST notification. <<1/6/01; 8:46:28 PM by DW <<Logging code is controlled by a preference. <<1/6/01; 3:46:22 PM by JES <<Changed the value of the 1st and 3rd parameters in the SOAP implementation to supply the correct actionURI and methodName. <<1/5/01; 7:54:01 PM by DW <<Add SOAP implementation. <<1/5/01; 7:24:13 PM by DW <<Add a boolean parameter, if true, we resubscribe to all, our IP address might have changed. <<1/5/01; 5:32:13 PM by DW <<Created. Send a request to receive notification for channels that support clouds. <<Only send a request once every twenty-four hours. local (adrdata = river2Suite.init ()); if adrdata^.prefs.flRequestCloudNotify { local (startticks = clock.ticks (), htmltext = ""); local (adrfeed, now = clock.now ()); for adrfeed in @adrdata^.feeds { local (urlfeed = nameof (adrfeed^), linkfeed = "<a href=\"" + urlfeed + "\">" + adrfeed^.feedinfo.title + "</a>"); river2Suite.initFeed (urlfeed); if defined (adrfeed^.feedinfo.cloud) { <<edit (adrfeed) local (flsubscribe = true); if not flSubscribeAll { if (now - adrfeed^.stats.whenLastCloudRenew) < adrfeed^.prefs.ctSecsBetwRenews { //8/15/09 by DW flsubscribe = false}}; if flsubscribe { river2Suite.renewOneSubscription (adrfeed, @htmltext)}}}; <<bundle //old code that was factored, 9/17/09 by DW <<local (startticksthisrenew = clock.ticks ()) <<with adrfeed^.feedinfo.cloud <<try <<if protocol == "xml-rpc" <<local (server = "xmlrpc://" + domain + ":" + port + path) <<[server].[registerProcedure] ("river2.feedUpdated", 5337, "/RPC2", "xml-rpc", {urlfeed}) <<local (params = {"river2.feedUpdated", 5337, "/RPC2", "xml-rpc", {urlfeed}}) <<betty.rpc.client (domain, port, registerProcedure, @params, rpcPath: path) <<else <<if protocol == "http-post" //7/21/09 by DW <<bundle //request notification via to http-post, 9/7/09 by DW <<local (apiurl = "http://" + domain + ":" + port + path, params) <<new (tabletype, @params) <<params.notifyProcedure = "" <<params.port = 5337 <<params.path = "/river2/notify" <<params.protocol = "http-post" <<params.url1 = urlfeed <<local (xmltext = tcp.httppost (apiurl, @params), xstruct) <<xml.compile (xmltext, @xstruct) <<local (adrnotifyresult = xml.getaddress (@xstruct, "notifyResult")) <<local (flsuccess = xml.getattributevalue (adrnotifyresult, "success")) <<if not flsuccess <<scripterror (xml.getattributevalue (adrnotifyresult, "msg")) <<bundle //old code -- request notification via XML-RPC, switch to http-post, 9/7/09 by DW <<local (apiurl = "http://" + domain + ":" + port + path, params) <<new (tabletype, @params) <<params.notifyProcedure = "river2.feedUpdated" <<params.port = 5337 <<params.path = "/RPC2" <<params.protocol = "xml-rpc" <<params.url1 = urlfeed <<local (xmltext = tcp.httppost (apiurl, @params), xstruct) <<xml.compile (xmltext, @xstruct) <<local (adrnotifyresult = xml.getaddress (@xstruct, "notifyResult")) <<local (flsuccess = xml.getattributevalue (adrnotifyresult, "success")) <<if not flsuccess <<scripterror (xml.getattributevalue (adrnotifyresult, "msg")) <<if protocol == "soap" <<local (params = {"channelChanged", user.inetd.config.http.port, "/aggregator", "soap", {urlfeed}}) <<soap.rpc.client (path, registerProcedure, @params, domain, port) <<htmltext = htmltext + linkfeed + ", " <<else <<adrfeed^.stats.lastCloudRenewError = tryerror //7/19/09 by DW <<adrfeed^.stats.ctCloudRenewErrors++ //8/16/09 by DW <<log2.add (river2Info.name, "Notify", "Error renewing " + linkfeed + ": \"" + tryerror + ".\"", startticksthisrenew) <<adrfeed^.stats.whenLastCloudRenew = now <<adrfeed^.stats.ctCloudRenew++ //7/25/09 by DW if htmltext != "" { htmltext = string.delete (htmltext, sizeof (htmltext) - 1, 2); //pop off last comma + space htmltext = "Requested notification when the following feeds update: " + htmltext + "."; log2.add (river2Info.name, "Notify", htmltext, startticks)}}}; bundle { //test code renewSubscriptions (false)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.