diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-11-03 19:50:40 -0800 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-11-03 19:50:40 -0800 |
commit | 2fbfc2a8f176ef6ca9389f04b67e5734596ed0da (patch) | |
tree | 0738c93d610b5d3694199764feb7e93db1f8699d /mod | |
parent | e09b49288fa415c85d5ee1e77218c0b4c2b54a1d (diff) | |
download | volse-hubzilla-2fbfc2a8f176ef6ca9389f04b67e5734596ed0da.tar.gz volse-hubzilla-2fbfc2a8f176ef6ca9389f04b67e5734596ed0da.tar.bz2 volse-hubzilla-2fbfc2a8f176ef6ca9389f04b67e5734596ed0da.zip |
need better peer verification due to re-install issue, this is temporary
Diffstat (limited to 'mod')
-rw-r--r-- | mod/post.php | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/mod/post.php b/mod/post.php index 00e599b49..e03e1321b 100644 --- a/mod/post.php +++ b/mod/post.php @@ -663,16 +663,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); @@ -680,41 +680,48 @@ 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']) - ); + // 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 - // a dead hub came back to life - reset any tombstones we might have - - if(intval($hub['hubloc_error'])) { - q("update hubloc set hubloc_error = 0 where hubloc_id = %d", - intval($hub['hubloc_id']) + $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d", + dbesc(datetime_convert()), + intval($hub['hubloc_id']) ); - if(intval($r[0]['hubloc_orphancheck'])) { - q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d", - intval($hub['hubloc_id']) + + // a dead hub came back to life - reset any tombstones we might have + + if(intval($hub['hubloc_error'])) { + q("update hubloc set hubloc_error = 0 where hubloc_id = %d", + intval($hub['hubloc_id']) + ); + if(intval($r[0]['hubloc_orphancheck'])) { + q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d", + intval($hub['hubloc_id']) + ); + } + q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", + dbesc($hub['hubloc_hash']) ); } - q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", - dbesc($hub['hubloc_hash']) - ); - } - /* - * 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. - */ + /* + * 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_deleted = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ", - dbesc($hub['hubloc_url']), - dbesc($hub['hubloc_sitekey']) - ); + +// q("update hubloc set hubloc_deleted = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ", +// dbesc($hub['hubloc_url']), +// dbesc($hub['hubloc_sitekey']) +// ); + + $connecting_url = $hub['hubloc_url']; + + } /** @TODO check which hub is primary and take action if mismatched */ @@ -917,7 +924,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'); |