more dir sync testing

This commit is contained in:
Mario Vavti
2023-04-28 00:58:46 +02:00
parent 1f81a2cb1b
commit 5412ba617d

View File

@@ -288,7 +288,7 @@ class Libzotdir {
// the host is trusted and flags have changed // the host is trusted and flags have changed
if (in_array($t['host'], $dir_trusted_hosts) && if (in_array($t['host'], $dir_trusted_hosts) &&
$rr['site_directory'] === $t['host'] && $rr['site_url'] === $t['host'] &&
intval($r[0]['ud_flags']) !== intval($t['flags'])) { intval($r[0]['ud_flags']) !== intval($t['flags'])) {
$update = (($update) ? DIRECTORY_UPDATE_BOTH : DIRECTORY_UPDATE_FLAGS); $update = (($update) ? DIRECTORY_UPDATE_BOTH : DIRECTORY_UPDATE_FLAGS);
@@ -298,6 +298,15 @@ class Libzotdir {
continue; continue;
} }
if (in_array($update, [DIRECTORY_UPDATE_FLAGS, DIRECTORY_UPDATE_BOTH])) {
q("UPDATE updates SET ud_update = %d, ud_flags = %d WHERE ud_id = %d",
intval($update),
intval($t['flags']),
dbesc($r[0]['ud_id'])
);
continue;
}
q("UPDATE updates SET ud_update = %d WHERE ud_id = %d", q("UPDATE updates SET ud_update = %d WHERE ud_id = %d",
intval($update), intval($update),
dbesc($r[0]['ud_id']) dbesc($r[0]['ud_id'])
@@ -339,14 +348,15 @@ class Libzotdir {
logger('update_directory_entry: ' . print_r($ud,true), LOGGER_DATA); logger('update_directory_entry: ' . print_r($ud,true), LOGGER_DATA);
// set the flag if requested? // set the flag if requested?
if (in_array($ud['ud_flags'], [DIRECTORY_UPDATE_FLAGS, DIRECTORY_UPDATE_BOTH])) { if (in_array($ud['ud_update'], [DIRECTORY_UPDATE_FLAGS, DIRECTORY_UPDATE_BOTH])) {
q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'", q("UPDATE xchan SET xchan_censored = %d WHERE xchan_hash = '%s'",
intval($ud['ud_flags']), intval($ud['ud_flags']),
dbesc($ud['ud_hash']) dbesc($ud['ud_hash'])
); );
} }
if (intval($ud['ud_flags']) === DIRECTORY_UPDATE_FLAGS) { if (intval($ud['ud_update']) === DIRECTORY_UPDATE_FLAGS) {
self::update($ud['ud_hash'], $ud['ud_addr'], $ud['ud_flags'], false); self::update($ud['ud_hash'], $ud['ud_addr'], $ud['ud_flags'], false);
return true; return true;
} }