From b6b2420ff77fb1c19306dfc8be2b916e5a34c375 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 3 Nov 2015 23:54:53 -0800 Subject: protocol upgrade --- mod/post.php | 92 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 36 deletions(-) (limited to 'mod') diff --git a/mod/post.php b/mod/post.php index 682e04818..c68ce9646 100644 --- a/mod/post.php +++ b/mod/post.php @@ -673,16 +673,16 @@ function post_post(&$a) { /* Check if the sender is already verified here */ - $hub = zot_gethub($sender); + $hubs = zot_gethub($sender,true); - if (! $hub) { + if (! $hubs) { /* Have never seen this guid or this guid coming from this location. Check it and register it. */ // (!!) this will validate the sender $result = zot_register_hub($sender); - if ((! $result['success']) || (! ($hub = zot_gethub($sender)))) { + if ((! $result['success']) || (! ($hubs = zot_gethub($sender,true)))) { $ret['message'] = 'Hub not available.'; logger('mod_zot: no hub'); json_return_and_die($ret); @@ -690,46 +690,66 @@ function post_post(&$a) { } - // Update our DB to show when we last communicated successfully with this hub - // This will allow us to prune dead hubs from using up resources + foreach($hubs as $hub) { - $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d", - dbesc(datetime_convert()), - intval($hub['hubloc_id']) - ); + $sitekey = $hub['hubloc_sitekey']; - // a dead hub came back to life - reset any tombstones we might have + if(array_key_exists('sitekey',$sender) && $sender['sitekey']) { - if ($hub['hubloc_status'] & HUBLOC_OFFLINE) { - q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d", - intval(HUBLOC_OFFLINE), - intval($hub['hubloc_id']) - ); - if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { - q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_ORPHANCHECK), - intval($hub['hubloc_id']) + /* + * This hub has now been proven to be valid. + * Any hub with the same URL and a different sitekey cannot be valid. + * Get rid of them (mark them deleted). There's a good chance they were re-installs. + */ + + q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ", + intval(HUBLOC_FLAGS_DELETED), + dbesc($hub['hubloc_url']), + dbesc($sender['sitekey']) ); + + $sitekey = $sender['sitekey']; } - q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'", - intval(XCHAN_FLAGS_ORPHAN), - intval(XCHAN_FLAGS_ORPHAN), - dbesc($hub['hubloc_hash']) + + // $sender['sitekey'] is a new addition to the protcol to distinguish + // hublocs coming from re-installed sites. Older sites will not provide + // this field and we have to still mark them valid, since we can't tell + // if this hubloc has the same sitekey as the packet we received. + + // Update our DB to show when we last communicated successfully with this hub + // This will allow us to prune dead hubs from using up resources + + $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_sitekey = '%s' ", + dbesc(datetime_convert()), + intval($hub['hubloc_id']), + dbesc($sitekey) ); - } + // a dead hub came back to life - reset any tombstones we might have - /* - * This hub has now been proven to be valid. - * Any hub with the same URL and a different sitekey cannot be valid. - * Get rid of them (mark them deleted). There's a good chance they were re-installs. - */ -// fixed in hubzilla with a protocol change -// q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ", -// intval(HUBLOC_FLAGS_DELETED), -// dbesc($hub['hubloc_url']), -// dbesc($hub['hubloc_sitekey']) -// ); + if ($hub['hubloc_status'] & HUBLOC_OFFLINE) { + q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d and hubloc_sitekey = '%s' ", + intval(HUBLOC_OFFLINE), + intval($hub['hubloc_id']), + dbesc($sitekey) + ); + if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { + q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d and hubloc_sitekey = '%s' ", + intval(HUBLOC_FLAGS_ORPHANCHECK), + intval($hub['hubloc_id']), + dbesc($sitekey) + ); + } + + q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'", + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_ORPHAN), + dbesc($hub['hubloc_hash']) + ); + } + + $connecting_url = $hub['hubloc_url']; + } /** @TODO check which hub is primary and take action if mismatched */ @@ -932,7 +952,7 @@ function post_post(&$a) { if ($msgtype === 'notify') { - logger('notify received from ' . $hub['hubloc_url']); + logger('notify received from ' . $connecting_url); $async = get_config('system','queued_fetch'); -- cgit v1.2.3 From f4a9529968fedb65289d49ec0901739df17df698 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 4 Nov 2015 17:47:24 -0800 Subject: Firefox Share API provider interface (first cut, only has share ability) --- mod/ffsapi.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 mod/ffsapi.php (limited to 'mod') diff --git a/mod/ffsapi.php b/mod/ffsapi.php new file mode 100644 index 000000000..15cc8365f --- /dev/null +++ b/mod/ffsapi.php @@ -0,0 +1,64 @@ + + +var baseurl = '$baseurl'; + +var data = { + "origin": baseurl, + // currently required + "name": '$name', + "iconURL": baseurl+"/images/hz-16.png", + "icon32URL": baseurl+"/images/hz-32.png", + "icon64URL": baseurl+"/images/hz-64.png", + + // at least one of these must be defined + // "workerURL": baseurl+"/worker.js", + // "sidebarURL": baseurl+"/sidebar.htm", + "shareURL": baseurl+"/rpost?f=&url=%{url}", + + // status buttons are scheduled for Firefox 26 or 27 + //"statusURL": baseurl+"/statusPanel.html", + + // social bookmarks are available in Firefox 26 + //"markURL": baseurl+"/mark.html?url=%{url}", + // icons should be 32x32 pixels + //"markedIcon": baseurl+"/unchecked.jpg", + //"unmarkedIcon": baseurl+"/checked.jpg", + + // should be available for display purposes + "description": '$description', + "author": '$author', + "homepageURL": '$homepage', + + // optional + "version": "1.0" +} + +function activate(node) { + var event = new CustomEvent("ActivateSocialFeature"); + var jdata = JSON.stringify(data); + node.setAttribute("data-service", JSON.stringify(data)); + node.dispatchEvent(event); +} + + + + +EOT; + +return $s; + +} \ No newline at end of file -- cgit v1.2.3 From 5dfaeaf526a115a4699cebed7a28b97a7aad019f Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 4 Nov 2015 18:15:03 -0800 Subject: add bookmarking to FF social api provider --- mod/ffsapi.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/ffsapi.php b/mod/ffsapi.php index 15cc8365f..24ff9d5e0 100644 --- a/mod/ffsapi.php +++ b/mod/ffsapi.php @@ -33,10 +33,10 @@ var data = { //"statusURL": baseurl+"/statusPanel.html", // social bookmarks are available in Firefox 26 - //"markURL": baseurl+"/mark.html?url=%{url}", + "markURL": baseurl+"/bmark?f=&url=%{url}&title=%{title}", // icons should be 32x32 pixels - //"markedIcon": baseurl+"/unchecked.jpg", - //"unmarkedIcon": baseurl+"/checked.jpg", + "markedIcon": baseurl+"/images/checkbox-checked-32.png", + "unmarkedIcon": baseurl+"/images/checkbox-unchecked-32.png", // should be available for display purposes "description": '$description', -- cgit v1.2.3 From 42c0f83ec5cd6d54c190832db1d432f69576e104 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 4 Nov 2015 18:21:36 -0800 Subject: typo --- mod/ffsapi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/ffsapi.php b/mod/ffsapi.php index 24ff9d5e0..a75e60bcc 100644 --- a/mod/ffsapi.php +++ b/mod/ffsapi.php @@ -33,7 +33,7 @@ var data = { //"statusURL": baseurl+"/statusPanel.html", // social bookmarks are available in Firefox 26 - "markURL": baseurl+"/bmark?f=&url=%{url}&title=%{title}", + "markURL": baseurl+"/rbmark?f=&url=%{url}&title=%{title}", // icons should be 32x32 pixels "markedIcon": baseurl+"/images/checkbox-checked-32.png", "unmarkedIcon": baseurl+"/images/checkbox-unchecked-32.png", -- cgit v1.2.3 From 5f1ccc25b6ee38d7d6408f555a932fcee41f8fbf Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 4 Nov 2015 18:34:42 -0800 Subject: menu_list() takes a channel_id, not the whole channel array --- mod/rbmark.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/rbmark.php b/mod/rbmark.php index cbd32098b..4401e3626 100644 --- a/mod/rbmark.php +++ b/mod/rbmark.php @@ -77,7 +77,9 @@ function rbmark_content(&$a) { $channel = $a->get_channel(); - $m = menu_list($channel,'',MENU_BOOKMARK); + + $m = menu_list($channel['channel_id'],'',MENU_BOOKMARK); + $menus = array(); if($m) { $menus = array(0 => ''); -- cgit v1.2.3