From 5da58d42f6b86d6aa026444a9163909eb5e0d49d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 27 Apr 2023 22:26:53 +0200 Subject: adjust args in libzotdir update and some dir sync fixes --- Zotlabs/Lib/Libzot.php | 2 +- Zotlabs/Lib/Libzotdir.php | 8 +++++--- Zotlabs/Module/Dircensor.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 1843a081d..d34afb83d 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -969,7 +969,7 @@ class Libzot { } // update updates if anything changed bump the ud_date - Libzotdir::update($xchan_hash, $address, $changed, $xchan_censored); + Libzotdir::update($xchan_hash, $address, $xchan_censored, $changed); if (empty($ret['message'])) { $ret['success'] = true; diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php index b000c0a69..5677d2263 100644 --- a/Zotlabs/Lib/Libzotdir.php +++ b/Zotlabs/Lib/Libzotdir.php @@ -282,7 +282,7 @@ class Libzotdir { } // there is more recent xchan information - if ($r[0]['ud_date'] >= $t['timestamp']) { + if ($r[0]['ud_date'] <= $t['timestamp']) { $update = DIRECTORY_UPDATE_XCHAN; } @@ -347,6 +347,7 @@ class Libzotdir { } if (intval($ud['ud_flags']) === DIRECTORY_UPDATE_FLAGS) { + self::update($ud['ud_hash'], $ud['ud_addr'], $ud['ud_flags'], false); return true; } @@ -355,6 +356,7 @@ class Libzotdir { $zf = Zotfinger::exec($href); if($zf && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { $xc = Libzot::import_xchan($zf['data']); + // This is a workaround for a missing xchan_updated column // TODO: implement xchan_updated in the xchan table and update this column instead if($zf['data']['primary_location']['address'] && $zf['data']['primary_location']['url']) { @@ -459,7 +461,7 @@ class Libzotdir { ); } - self::update($hash, $p[0]['xchan_url']); + self::update($hash, $p[0]['xchan_url'], $p[0]['xchan_censored']); } @@ -667,7 +669,7 @@ class Libzotdir { * @param bool $bump_date (optional) default true */ - static function update($hash, $addr, $bump_date = true, $flag = DIRECTORY_FLAG_OK) { + static function update($hash, $addr, $flag, $bump_date = true) { $dirmode = intval(get_config('system', 'directory_mode')); diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php index 44c9148e8..b372bbf25 100644 --- a/Zotlabs/Module/Dircensor.php +++ b/Zotlabs/Module/Dircensor.php @@ -45,7 +45,7 @@ class Dircensor extends Controller { $flag = DIRECTORY_FLAG_HIDDEN; } - Libzotdir::update($xchan, $r[0]['xchan_url'], true, $flag); + Libzotdir::update($xchan, $r[0]['xchan_url'], $flag); q("update xchan set xchan_censored = %d where xchan_hash = '%s'", intval($flag), -- cgit v1.2.3