From 25424c16e41dc4773a7464129cac7a9acd4667dc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 3 Feb 2022 19:09:15 +0000 Subject: unpack encoded mid and make sure to goaway to the right message --- Zotlabs/Module/Search.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 5db0ce423..1df45233c 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -58,10 +58,22 @@ class Search extends Controller { $o .= search($search, 'search-box', '/search', ((local_channel()) ? true : false)); if (local_channel() && strpos($search, 'https://') === 0 && !$update && !$load) { + if (strpos($search, 'b64.') !== false) { + $search = unpack_link_id(basename($search)); + } + $f = Libzot::fetch_conversation(App::get_channel(), punify($search), true); if ($f) { - goaway(z_root() . '/hq/' . gen_link_id($f['message_id'])); + $mid = $f[0]['message_id']; + foreach ($f as $m) { + if (strpos($search, $m['message_id']) === 0) { + $mid = $m['message_id']; + break; + } + } + + goaway(z_root() . '/hq/' . gen_link_id($mid)); } else { // try other fetch providers (e.g. diaspora, pubcrawl) -- cgit v1.2.3 From cb6055c1b83ba7811c452334d64c3981cca1a326 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 4 Feb 2022 12:48:47 +0000 Subject: clean the url from parameters --- Zotlabs/Module/Search.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 1df45233c..6f8fbdfbf 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -7,6 +7,7 @@ use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Activity; use Zotlabs\Lib\ActivityStreams; use Zotlabs\Web\Controller; +use Zotlabs\Lib\Zotfinger; class Search extends Controller { @@ -59,6 +60,10 @@ class Search extends Controller { if (local_channel() && strpos($search, 'https://') === 0 && !$update && !$load) { if (strpos($search, 'b64.') !== false) { + if (strpos($search, '?') !== false) { + $search = strtok($search, '?'); + } + $search = unpack_link_id(basename($search)); } -- cgit v1.2.3 From a0e8e40f1c9b60afd901091df792cafcc943a0a4 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 4 Feb 2022 12:50:25 +0000 Subject: whitespace --- Zotlabs/Module/Search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 6f8fbdfbf..fdc251b07 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -60,9 +60,9 @@ class Search extends Controller { if (local_channel() && strpos($search, 'https://') === 0 && !$update && !$load) { if (strpos($search, 'b64.') !== false) { - if (strpos($search, '?') !== false) { + if (strpos($search, '?') !== false) { $search = strtok($search, '?'); - } + } $search = unpack_link_id(basename($search)); } -- cgit v1.2.3 From a8d87af41844c8598a9ef58a8f900831d1f7ea03 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 8 Feb 2022 14:09:54 +0000 Subject: to reduce overall network fetches cache actors in Activity::fetch() and fetch the ldsig creator with get_actor() instead of get_compound_property() so that it will check the cache before actually fetching --- Zotlabs/Lib/Activity.php | 12 ++++++++++-- Zotlabs/Lib/ActivityStreams.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 159f2a46f..e51922c86 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -116,6 +116,11 @@ class Activity { $y = json_decode($x['body'], true); logger('returned: ' . json_encode($y, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOGGER_DEBUG); + + if (ActivityStreams::is_an_actor($y['type'])) { + XConfig::Set($y['id'], 'system', 'actor_record', $y); + } + return json_decode($x['body'], true); } else { @@ -3709,7 +3714,10 @@ class Activity { } static function get_cached_actor($id) { - $actor = XConfig::Get($id, 'system', 'actor_record'); + + // remove any fragments like #main-key since these won't be present in our cached data + $cache_url = ((strpos($id, '#')) ? substr($id, 0, strpos($id, '#')) : $id); + $actor = XConfig::Get($cache_url, 'system', 'actor_record'); if ($actor) { return $actor; @@ -3718,7 +3726,7 @@ class Activity { // try other get_cached_actor providers (e.g. diaspora) $hookdata = [ 'id' => $id, - 'actor' => false + 'actor' => null ]; call_hooks('get_cached_actor_provider', $hookdata); diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index b86203a34..275f6eff4 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -92,7 +92,7 @@ class ActivityStreams { $this->ldsig = $this->get_compound_property('signature'); if ($this->ldsig) { - $this->signer = $this->get_compound_property('creator', $this->ldsig); + $this->signer = $this->get_actor('creator', $this->ldsig); if ($this->signer && is_array($this->signer) && array_key_exists('publicKey', $this->signer) && is_array($this->signer['publicKey']) && $this->signer['publicKey']['publicKeyPem']) { $this->sigok = LDSignatures::verify($this->data, $this->signer['publicKey']['publicKeyPem']); } -- cgit v1.2.3