From 35df50c39d95e19dcd7e67bd3328059dbb591b66 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 21 Apr 2021 07:55:35 +0000 Subject: start sending author id, id_sig and key fields along with author/owner and adjust import_author_xchan() accordingly --- Zotlabs/Lib/Libzot.php | 6 +++--- include/items.php | 28 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index db35dfb70..a19c8e544 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2664,9 +2664,9 @@ class Libzot { // we may only end up with one; which results in posts with no author name or photo and are a bit // of a hassle to repair. If either or both are missing, do a full discovery probe. - if (!array_key_exists('id', $x)) { - return import_author_activitypub($x); - } + //if (!array_key_exists('id', $x)) { + //return import_author_activitypub($x); + //} $hash = self::make_xchan_hash($x['id'], $x['key']); diff --git a/include/items.php b/include/items.php index 8b22a7b4c..0d1047e13 100644 --- a/include/items.php +++ b/include/items.php @@ -908,7 +908,6 @@ function get_item_elements($x,$allow_code = false) { $arr['item_type'] = ITEM_TYPE_DOC; } } - return $arr; } @@ -926,17 +925,26 @@ function import_author_xchan($x) { * * \e string \b xchan_hash - Thre returned value */ call_hooks('import_author_xchan', $arr); - if($arr['xchan_hash']) + if($arr['xchan_hash']) { return $arr['xchan_hash']; + } $y = false; - if((! array_key_exists('network', $x)) || ($x['network'] === 'zot')) { + if((isset($x['id']) && isset($x['key'])) && (!isset($x['network']) || $x['network'] === 'zot6')) { + $y = Libzot::import_author_zot($x); + } + + if(!isset($x['network']) || $x['network'] === 'zot') { $y = import_author_zot($x); } - // if we were told that it's a zot connection, don't probe/import anything else - if(array_key_exists('network',$x) && $x['network'] === 'zot') { + // if we were told that it's a zot6 connection, don't probe/import anything else + if(isset($x['network']) && $x['network'] === 'zot6') { + return $y; + } + + if(isset($x['network']) && $x['network'] === 'zot') { if($x['url']) { // check if we already have the zot6 xchan of this xchan_url. if not import it. $r = q("SELECT xchan_hash FROM xchan WHERE xchan_url = '%s' AND xchan_network = 'zot6'", @@ -951,10 +959,8 @@ function import_author_xchan($x) { } // perform zot6 discovery - if($x['url']) { - $y = discover_by_webbie($x['url'],'zot6'); - + $y = discover_by_webbie($x['url'], 'zot6'); if($y) { return $y; } @@ -968,7 +974,7 @@ function import_author_xchan($x) { $y = import_author_unknown($x); } - return($y); + return $y; } /** @@ -1296,6 +1302,10 @@ function encode_item_xchan($xchan) { $ret['guid'] = $xchan['xchan_guid']; $ret['guid_sig'] = $xchan['xchan_guid_sig']; + $ret['id'] = $xchan['xchan_guid']; + $ret['id_sig'] = $xchan['xchan_guid_sig']; + $ret['key'] = $xchan['xchan_pubkey']; + return $ret; } -- cgit v1.2.3