diff options
author | Mario <mario@mariovavti.com> | 2023-07-03 10:37:32 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-07-03 10:37:32 +0000 |
commit | 7a0f22b0a7d909518c22264d524f584c9d2df456 (patch) | |
tree | cc09d3c6353f001b010e02dc72d96d82f63e2302 /Zotlabs/Lib/Activity.php | |
parent | 4f03272a5f4c33f6c893b6f56f43fe5e839173b3 (diff) | |
download | volse-hubzilla-7a0f22b0a7d909518c22264d524f584c9d2df456.tar.gz volse-hubzilla-7a0f22b0a7d909518c22264d524f584c9d2df456.tar.bz2 volse-hubzilla-7a0f22b0a7d909518c22264d524f584c9d2df456.zip |
make sure to return infos from current hub where applicable - fix issue #1770
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4a89842f2..ce2a75d41 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1054,19 +1054,19 @@ class Activity { static function encode_person($p, $extended = true) { - $id = ((filter_var($p['xchan_hash'], FILTER_VALIDATE_URL)) ? $p['xchan_hash'] : $p['xchan_url']); + $c = ((array_key_exists('channel_id', $p)) ? $p : channelx_by_hash($p['xchan_hash'])); - if (!$extended) { - return $id; - } + $id = (($c) ? channel_url($c) : $p['xchan_url']); - $ret = []; + $ret = (($extended) ? [] : ''); if (!$id) { return $ret; } - $c = ((array_key_exists('channel_id', $p)) ? $p : channelx_by_hash($p['xchan_hash'])); + if (!$extended) { + return $id; + } $ret['type'] = 'Person'; @@ -1078,15 +1078,9 @@ class Activity { $ret['manuallyApprovesFollowers'] = ((get_pconfig($c['channel_id'], 'system', 'autoperms')) ? false : true); } - if ($c) { - $ret['id'] = channel_url($c); - } - else { - $ret['id'] = $id; - } + $ret['id'] = $id; - if ($p['xchan_addr'] && strpos($p['xchan_addr'], '@')) - $ret['preferredUsername'] = substr($p['xchan_addr'], 0, strpos($p['xchan_addr'], '@')); + $ret['preferredUsername'] = (($c) ? $c['channel_address'] : substr($p['xchan_addr'], 0, strpos($p['xchan_addr'], '@'))); $ret['name'] = $p['xchan_name']; $ret['updated'] = datetime_convert('UTC', 'UTC', $p['xchan_name_date'], ATOM_TIME); @@ -1124,11 +1118,11 @@ class Activity { ]; */ - $ret['url'] = $p['xchan_url']; + $ret['url'] = $id; $ret['publicKey'] = [ - 'id' => $p['xchan_url'], - 'owner' => $p['xchan_url'], + 'id' => $id, + 'owner' => $id, 'signatureAlgorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', 'publicKeyPem' => $p['xchan_pubkey'] ]; @@ -1151,6 +1145,7 @@ class Activity { call_hooks('encode_person', $arr); $ret = $arr['encoded']; + return $ret; } |