From 81338e80865caff4c911980c0cb9689cb10c7087 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 10:10:07 +0000 Subject: use zot_record_preferred() when fetching keys --- Zotlabs/Lib/JSalmon.php | 2 +- Zotlabs/Web/HTTPSig.php | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php index bed748432..67512046f 100644 --- a/Zotlabs/Lib/JSalmon.php +++ b/Zotlabs/Lib/JSalmon.php @@ -69,4 +69,4 @@ class JSalmon { } -} \ No newline at end of file +} diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 3d050fd9b..827e0d779 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -243,13 +243,15 @@ class HTTPSig { $url = ((strpos($id,'#')) ? substr($id,0,strpos($id,'#')) : $id); - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$url)), dbesc($url) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $r = ActivityStreams::fetch($id); @@ -268,13 +270,15 @@ class HTTPSig { function get_webfinger_key($id) { - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$id)), dbesc($id) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $wf = Webfinger::exec($id); @@ -302,12 +306,15 @@ class HTTPSig { function get_zotfinger_key($id) { - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$id)), dbesc($id) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $wf = Webfinger::exec($id); -- cgit v1.2.3