aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Web
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-08 19:51:10 +0000
committerMario <mario@mariovavti.com>2022-02-08 19:51:10 +0000
commitc0dd4d748db3e07d49ae72e2e37d0cc5c74011c4 (patch)
tree445c561f7461d50ab00d71080edc53e1c21ddfce /Zotlabs/Web
parentc94f25570b94ba2f389fbd1ad9f547a10e962e24 (diff)
downloadvolse-hubzilla-c0dd4d748db3e07d49ae72e2e37d0cc5c74011c4.tar.gz
volse-hubzilla-c0dd4d748db3e07d49ae72e2e37d0cc5c74011c4.tar.bz2
volse-hubzilla-c0dd4d748db3e07d49ae72e2e37d0cc5c74011c4.zip
HTTPSig: introduce the deleted keytype. this will allow us to not fetch an actor we have never seen before if we received a delete activity for this actor for some reason. this is only implemented in the activitypub inbox so far.
Diffstat (limited to 'Zotlabs/Web')
-rw-r--r--Zotlabs/Web/HTTPSig.php36
1 files changed, 30 insertions, 6 deletions
diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php
index 7da9acabf..e5d73293a 100644
--- a/Zotlabs/Web/HTTPSig.php
+++ b/Zotlabs/Web/HTTPSig.php
@@ -156,6 +156,7 @@ class HTTPSig {
$cached_key = self::get_key($key, $keytype, $result['signer']);
+
if (!($cached_key && $cached_key['public_key'])) {
return $result;
}
@@ -229,21 +230,26 @@ class HTTPSig {
return ['public_key' => $key];
}
+ $deleted = false;
+ if ($keytype === 'deleted') {
+ $deleted = true;
+ }
+
if ($keytype === 'zot6') {
- $key = self::get_zotfinger_key($id, $force);
+ $key = self::get_zotfinger_key($id, $force, $deleted);
if ($key) {
return $key;
}
}
if (strpos($id, '#') === false) {
- $key = self::get_webfinger_key($id, $force);
+ $key = self::get_webfinger_key($id, $force, $deleted);
if ($key) {
return $key;
}
}
- $key = self::get_activitystreams_key($id, $force);
+ $key = self::get_activitystreams_key($id, $force, $deleted);
return $key;
@@ -274,7 +280,7 @@ class HTTPSig {
* false if no pub key found, otherwise return an array with the pub key
*/
- static function get_activitystreams_key($id, $force = false) {
+ static function get_activitystreams_key($id, $force = false, $deleted = false) {
// Check the local cache first, but remove any fragments like #main-key since these won't be present in our cached data
$url = ((strpos($id, '#')) ? substr($id, 0, strpos($id, '#')) : $id);
@@ -294,6 +300,12 @@ class HTTPSig {
}
}
+ if ($deleted) {
+ // If we received a delete and we do not have the record cached,
+ // we probably never saw this actor. Do not try to fetch it now.
+ return false;
+ }
+
// The record wasn't in cache. Fetch it now.
$r = ActivityStreams::fetch($id);
@@ -319,7 +331,7 @@ class HTTPSig {
* false if no pub key found, otherwise return an array with the pub key
*/
- static function get_webfinger_key($id, $force = false) {
+ static function get_webfinger_key($id, $force = false, $deleted = false) {
if (!$force) {
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s' and hubloc_network in ('zot6', 'activitypub') order by hubloc_id desc",
@@ -335,6 +347,12 @@ class HTTPSig {
}
}
+ if ($deleted) {
+ // If we received a delete and we do not have the record cached,
+ // we probably never saw this actor. Do not try to fetch it now.
+ return false;
+ }
+
$wf = Webfinger::exec($id);
$key = ['portable_id' => '', 'public_key' => '', 'hubloc' => []];
@@ -366,7 +384,7 @@ class HTTPSig {
* false if no pub key found, otherwise return an array with the public key
*/
- static function get_zotfinger_key($id, $force = false) {
+ static function get_zotfinger_key($id, $force = false, $deleted = false) {
if (!$force) {
$x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc",
dbesc($id)
@@ -381,6 +399,12 @@ class HTTPSig {
}
}
+ if ($deleted) {
+ // If we received a delete and we do not have the record cached,
+ // we probably never saw this actor. Do not try to fetch it now.
+ return false;
+ }
+
$wf = Webfinger::exec($id);
$key = ['portable_id' => '', 'public_key' => '', 'hubloc' => []];