diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index f858e6ede..18630ac05 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -153,13 +153,13 @@ class Notifier { } elseif (in_array($cmd, [ 'permissions_update', 'permissions_reject', 'permissions_accept', 'permissions_create' ])) { - // Get the (single) recipient - + // Get the (single) recipient + $r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_self = 0", intval($item_id) ); - if ($r) { + $recip = array_shift($r); $uid = $recip['abook_channel']; // Get the sender diff --git a/Zotlabs/Lib/ActivityPub.php b/Zotlabs/Lib/ActivityPub.php index 01dcddfad..e79f5d4f5 100644 --- a/Zotlabs/Lib/ActivityPub.php +++ b/Zotlabs/Lib/ActivityPub.php @@ -484,7 +484,9 @@ class ActivityPub { } } } + if (isset($person_obj)) { + Activity::actor_store($person_obj['id'],$person_obj, $force); return $person_obj['id']; } diff --git a/Zotlabs/Lib/Nodeinfo.php b/Zotlabs/Lib/Nodeinfo.php index 2361c6ae0..62efd7583 100644 --- a/Zotlabs/Lib/Nodeinfo.php +++ b/Zotlabs/Lib/Nodeinfo.php @@ -15,10 +15,17 @@ class Nodeinfo { if ($n['success']) { $j = json_decode($n['body'], true); if ($j && $j['links']) { - foreach ($j['links'] as $l) { - if ($l['rel'] === 'http://nodeinfo.diaspora.software/ns/schema/2.0' && $l['href']) { - $href = $l['href']; - + // lemmy just sends one result + if (isset($j['links']['rel'])) { + if ($j['links']['rel'] === 'http://nodeinfo.diaspora.software/ns/schema/2.0' && isset($j['links']['href'])) { + $href = $j['links']['href']; + } + } + else { + foreach ($j['links'] as $l) { + if (isset($l['rel']) && $l['rel'] === 'http://nodeinfo.diaspora.software/ns/schema/2.0' && isset($l['href'])) { + $href = $l['href']; + } } } } diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 2b74e68ce..71bcec111 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -12,11 +12,31 @@ class Queue { static function update($id, $add_priority = 0) { logger('queue: requeue item ' . $id,LOGGER_DEBUG); - $x = q("select outq_created, outq_posturl from outq where outq_hash = '%s' limit 1", + + // This queue item failed. Perhaps it was rejected. Perhaps the site is dead. + // Since we don't really know, check and see if we've got something else destined + // for that server and give it priority. At a minimum it will keep the queue from + // getting stuck on a particular message when another one with different content + // might actually succeed. + + $x = q("select outq_created, outq_hash, outq_posturl from outq where outq_hash = '%s' limit 1", dbesc($id) ); - if(! $x) + if (! $x) { return; + } + + $g = q("select outq_created, outq_hash, outq_posturl from outq where outq_posturl = '%s' and outq_hash != '%s' limit 1", + dbesc($x[0]['outq_posturl']), + dbesc($id) + ); + + // swap them + + if ($g) { + $x = $g; + } + $y = q("select min(outq_created) as earliest from outq where outq_posturl = '%s'", @@ -46,7 +66,7 @@ class Queue { dbesc($x[0]['outq_posturl']) ); - $since = datetime_convert('UTC','UTC',$x[0]['outq_created']); + $since = datetime_convert('UTC','UTC',$y[0]['earliest']); if(($might_be_down) || ($since < datetime_convert('UTC','UTC','now - 12 hour'))) { $next = datetime_convert('UTC','UTC','now + 1 hour'); @@ -63,7 +83,7 @@ class Queue { dbesc(datetime_convert()), intval($add_priority), dbesc($next), - dbesc($id) + dbesc($x[0]['outq_hash']) ); } diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 81c45a29e..4b9d5b504 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -345,15 +345,37 @@ class HTTPSig { // The record wasn't in cache. Fetch it now. $r = Activity::fetch($id); + $signatureAlgorithm = EMPTY_STR; if ($r) { if (array_key_exists('publicKey',$r) && array_key_exists('publicKeyPem',$r['publicKey']) && array_key_exists('id',$r['publicKey'])) { if ($r['publicKey']['id'] === $id || $r['id'] === $id) { $portable_id = ((array_key_exists('owner',$r['publicKey'])) ? $r['publicKey']['owner'] : EMPTY_STR); + + // the w3c sec context has conflicting names and no defined values for this property except + // "http://www.w3.org/2000/09/xmldsig#rsa-sha1" + + // Since the names conflict, it could mess up LD-signatures but we will accept both, and at this + // time we will only look for the substrings 'rsa-sha256' and 'rsa-sha512' within those properties. + // We will also accept a toplevel 'sigAlgorithm' regardless of namespace with the same constraints. + // Default to rsa-sha256 if we can't figure out. If they're sending 'hs2019' we have to + // look for something. + if (isset($r['publicKey']['signingAlgorithm'])) { - set_xconfig($portable_id,'system','signing_algorithm',$r['publicKey']['signingAlgorithm']); + $signatureAlgorithm = $r['publicKey']['signingAlgorithm']; + set_xconfig($portable_id,'system','signing_algorithm',$signatureAlgorithm); } - return [ 'public_key' => self::convertKey($r['publicKey']['publicKeyPem']), 'portable_id' => $portable_id, 'algorithm' => ((isset($r['publicKey']['signingAlgorithm'])) ? $r['publicKey']['signingAlgorithm'] : EMPTY_STR), 'hubloc' => [] ]; + if (isset($r['publicKey']['signatureAlgorithm'])) { + $signatureAlgorithm = $r['publicKey']['signatureAlgorithm']; + set_xconfig($portable_id,'system','signing_algorithm',$signatureAlgorithm); + } + + if (isset($r['sigAlgorithm'])) { + $signatureAlgorithm = $r['sigAlgorithm']; + set_xconfig($portable_id,'system','signing_algorithm',$signatureAlgorithm); + } + + return [ 'public_key' => self::convertKey($r['publicKey']['publicKeyPem']), 'portable_id' => $portable_id, 'algorithm' => (($signatureAlgorithm) ? $signatureAlgorithm : 'rsa-sha256'), 'hubloc' => [] ]; } } } diff --git a/boot.php b/boot.php index 70f36e779..fb7f70eee 100755 --- a/boot.php +++ b/boot.php @@ -17,7 +17,7 @@ use Zotlabs\Daemon\Run; * @brief This file defines some global constants and includes the central App class. */ -define ( 'STD_VERSION', '21.11.14' ); +define ( 'STD_VERSION', '21.11.20' ); define ( 'ZOT_REVISION', '10.0' ); define ( 'DB_UPDATE_VERSION', 1254 );