aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Zotfinger.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-01 10:01:56 +0000
committerMario <mario@mariovavti.com>2022-02-01 10:01:56 +0000
commiteb207898219937435f5735eb96fe32e5b2d489f0 (patch)
tree002da6491f1ed7f18d1b84a2a8155fd952aa7894 /Zotlabs/Lib/Zotfinger.php
parentc90862217ef29ee4f3d37d37a8fe6063aa68dbdf (diff)
downloadvolse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.tar.gz
volse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.tar.bz2
volse-hubzilla-eb207898219937435f5735eb96fe32e5b2d489f0.zip
allow zotfinger to recurse through all known hublocs if the one we got does not exist (404) or got removed (410). add functions for updating tables from array and deleting hublocs.
Diffstat (limited to 'Zotlabs/Lib/Zotfinger.php')
-rw-r--r--Zotlabs/Lib/Zotfinger.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php
index 840d91403..58050609c 100644
--- a/Zotlabs/Lib/Zotfinger.php
+++ b/Zotlabs/Lib/Zotfinger.php
@@ -6,7 +6,7 @@ use Zotlabs\Web\HTTPSig;
class Zotfinger {
- static function exec($resource,$channel = null, $verify = true) {
+ static function exec($resource, $channel = null, $verify = true, $recurse = true) {
if(! $resource) {
return false;
@@ -39,6 +39,30 @@ class Zotfinger {
logger('fetch: ' . print_r($x,true));
+ if (in_array(intval($x['return_code']), [ 404, 410 ]) && $recurse) {
+
+ // The resource has been deleted or doesn't exist at this location.
+ // Try to find another nomadic resource for this channel and return that.
+
+ // First, see if there's a hubloc for this site. Fetch that record to
+ // obtain the nomadic identity hash. Then use that to find any additional
+ // nomadic locations.
+
+ $h = Activity::get_actor_hublocs($resource, 'zot6');
+ if ($h) {
+ // mark this location deleted
+ hubloc_delete($h[0]);
+ $hubs = Activity::get_actor_hublocs($h[0]['hubloc_hash']);
+ if ($hubs) {
+ foreach ($hubs as $hub) {
+ if ($hub['hubloc_id_url'] !== $resource and !$hub['hubloc_deleted']) {
+ return $self::exec($hub['hubloc_id_url'],$channel,$verify);
+ }
+ }
+ }
+ }
+ }
+
if($x['success']) {
if ($verify) {
$result['signature'] = HTTPSig::verify($x, EMPTY_STR, 'zot6');