Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.outliner.requestNotifications

<<Changes
	<<8/29/02; 11:28:37 PM by JES
		<<Add the server to the Jabber user ID when requestion notification over Jabber.
	<<8/27/02; 2:12:12 AM by JES
		<<Update IM-based subscriptions every 24 hours.
	<<3/27/02; 2:17:31 AM by JES
		<<Created. Make an xmlStorageSystem.requestNotification RPC call for each subscribed outline, for which notification has not been requested within the last 24 hours.
local (adrdata = radio.outliner.init ());
local (userinfo); new (tableType, @userinfo);
bundle { //build userinfo table
	userinfo.subscriberName = user.prefs.name;
	userinfo.subscriberWeblogUrl = radio.weblog.getUrl ();
	local (outlineUrl = radio.upstream.getFileUrl (radio.outliner.getMyOutlineFile ()));
	userinfo.subscriberOutlineUrl = outlineUrl};
local (adrsub, now = clock.now (), twentyfourhours = 24 * 60 * 60, threehours = 3 * 60 * 60);
if user.radio.outliner.prefs.messaging.flEnabled {
	local (userinfo);
	bundle { //set up a userinfo table
		new (tableType, @userinfo);
		userinfo.name = user.prefs.name;
		userinfo.email = user.prefs.mailAddress;
		local (f = radio.outliner.getMyOutlineFile ());
		local (adrfile);
		radio.file.getfileattributes (f, @adrfile);
		userinfo.opmlUrl = adrfile^.upstream.url;
		userinfo.url = radio.weblog.getUrl ()};
	on subscribeToOutlinesForProtocol (protocol, myname) {
		local (adrsubs = @adrdata^.subscriptions);
		local (adr);
		for adr in adrsubs {
			if not defined (adr^.whenLastImSubscribe) {
				adr^.whenLastImSubscribe = date (0)};
			local (flsubscribe = true);
			if (now - adr^.whenLastImSubscribe) < threehours {
				flsubscribe = false};
			if flsubscribe {
				if defined (adr^.imRegisterProcedure) {
					if adr^.imRegisterProcedure.protocol == protocol {
						local (adrdriver);
						try { //RPI is asynch -- no error messages
							if tcp.im.findDriver (protocol, @adrdriver) { //make sure the protocol is handled
								with adr^.imRegisterProcedure {
									tcp.im.rpi.client (protocol, username, procedure, {protocol, "radioOutliner.opmlChanged", myname, userinfo})}}}
						else {
							msg (this + ": " + tryError)};
						adr^.whenLastImSubscribe = now}}}}};
	if adrdata^.prefs.messaging.flAimEnabled {
		subscribeToOutlinesForProtocol ("aim", user.im.aim.username)};
	if adrdata^.prefs.messaging.flJabberEnabled {
		subscribeToOutlinesForProtocol ("jabber", user.im.jabber.username + "@" + user.im.jabber.host)}};
if not user.radio.prefs.flBehindFirewall {
	local (startticks = clock.ticks (), htmltext = "");
	for adrsub in @adrdata^.subscriptions {
		if not defined (adrsub^.whenLastSubscribe) {
			adrsub^.whenLastSubscribe = date (0)};
		local (flsubscribe = true);
		if defined (adrsub^.whenLastSubscribe) {
			if (now - adrsub^.whenLastSubscribe) < twentyfourhours {
				flsubscribe = false}};
		if flsubscribe {
			try {
				if defined (adrsub^.cloudInfo) {
					local (url = nameOf (adrsub^));
					if adrsub^.cloudInfo.registerProcedure == "xmlStorageSystem.rssPleaseNotify" { //temporary workaround until people have all updated
						adrsub^.cloudInfo.registerProcedure = "xmlStorageSystem.requestNotification"};
					with adrsub^.cloudInfo {
						case protocol {
							"xml-rpc" {
								local (params = {"radioOutliner.opmlChanged", user.inetd.config.http.port, "/RPC2", "xml-rpc", {url}, userinfo});
								betty.rpc.client (domain, port, registerProcedure, @params, rpcPath: path)};
							"soap" {
								local (params = {"opmlChanged", user.inetd.config.http.port, "/radioOutliner", "soap", {url}, userinfo});
								soap.rpc.client (path, registerProcedure, @params, domain, port)}}};
					adrsub^.whenLastSubscribe = now;
					htmltext = htmltext + "<a href=\"" + url + "\">" + adrsub^.author + "</a> "}}}};
	if adrdata^.prefs.flLogNotificationRequests {
		if htmltext != "" {
			radio.log.add ("Outliner please notify", htmltext, startticks)}}}



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.