aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Libzotdir.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index 5677d2263..d9b5d7a35 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -357,6 +357,11 @@ class Libzotdir {
if($zf && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
$xc = Libzot::import_xchan($zf['data']);
+ // xchan_hash mismatch - this can happen after a site re-install at the same url
+ if ($xc['success'] && $xc['hash'] !== $ud['ud_hash']) {
+ self::delete_by_hash($ud['ud_hash']);
+ }
+
// 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']) {
@@ -365,6 +370,7 @@ class Libzotdir {
dbesc($zf['data']['primary_location']['url'])
);
}
+
return true;
}
}
@@ -714,4 +720,28 @@ class Libzotdir {
}
+
+ /**
+ * @brief deletes a entry in updates by hash
+ *
+ * @param string $hash the channel hash
+ * @return boolean
+ */
+
+ static function delete_by_hash($hash) {
+ if (!$hash) {
+ return false;
+ }
+
+ $x = q("DELETE FROM updates WHERE ud_hash = '%s'",
+ dbesc($hash)
+ );
+
+ if ($x) {
+ return true;
+ }
+
+ return false;
+ }
+
}