adjust args in libzotdir update and some dir sync fixes

This commit is contained in:
Mario Vavti
2023-04-27 22:26:53 +02:00
parent 299b6037c9
commit 5da58d42f6
3 changed files with 7 additions and 5 deletions

View File

@@ -969,7 +969,7 @@ class Libzot {
} }
// update updates if anything changed bump the ud_date // 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'])) { if (empty($ret['message'])) {
$ret['success'] = true; $ret['success'] = true;

View File

@@ -282,7 +282,7 @@ class Libzotdir {
} }
// there is more recent xchan information // there is more recent xchan information
if ($r[0]['ud_date'] >= $t['timestamp']) { if ($r[0]['ud_date'] <= $t['timestamp']) {
$update = DIRECTORY_UPDATE_XCHAN; $update = DIRECTORY_UPDATE_XCHAN;
} }
@@ -347,6 +347,7 @@ class Libzotdir {
} }
if (intval($ud['ud_flags']) === DIRECTORY_UPDATE_FLAGS) { if (intval($ud['ud_flags']) === DIRECTORY_UPDATE_FLAGS) {
self::update($ud['ud_hash'], $ud['ud_addr'], $ud['ud_flags'], false);
return true; return true;
} }
@@ -355,6 +356,7 @@ class Libzotdir {
$zf = Zotfinger::exec($href); $zf = Zotfinger::exec($href);
if($zf && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { if($zf && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
$xc = Libzot::import_xchan($zf['data']); $xc = Libzot::import_xchan($zf['data']);
// This is a workaround for a missing xchan_updated column // This is a workaround for a missing xchan_updated column
// TODO: implement xchan_updated in the xchan table and update this column instead // TODO: implement xchan_updated in the xchan table and update this column instead
if($zf['data']['primary_location']['address'] && $zf['data']['primary_location']['url']) { 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 * @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')); $dirmode = intval(get_config('system', 'directory_mode'));

View File

@@ -45,7 +45,7 @@ class Dircensor extends Controller {
$flag = DIRECTORY_FLAG_HIDDEN; $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'", q("update xchan set xchan_censored = %d where xchan_hash = '%s'",
intval($flag), intval($flag),