From 2a1a7e2e4628a89e95a82eca4196a51a40d5fb0e Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 24 Apr 2022 17:22:18 -0700 Subject: [PATCH] couple of tweaks --- Code/Lib/Activity.php | 31 +++++++++++++++++++++++-------- include/conversation.php | 18 +++++++++++------- include/items.php | 3 ++- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index 721283963..8a8235196 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -1570,13 +1570,28 @@ class Activity { $ret = []; - + $currhub = false; + if (!$p['xchan_url']) { return $ret; } + $h = q("select * from hubloc where hubloc_hash = '%s'", + dbesc($p['xchan_hash']) + ); + if ($h) { + $currhub = $h[0]; + foreach ($h as $hub) { + if ($hub['hubloc_url'] === z_root()) { + $currhub = $hub; + } + } + } + + $current_url = $currhub ? $currhub['hubloc_id_url'] : $p['xchan_url']; + if (!$extended) { - return $p['xchan_url']; + return $current_url; } $c = ((array_key_exists('channel_id', $p)) ? $p : Channel::from_hash($p['xchan_hash'])); @@ -1595,7 +1610,7 @@ class Activity if ($c) { $ret['id'] = Channel::url($c); } else { - $ret['id'] = ((strpos($p['xchan_hash'], 'http') === 0) ? $p['xchan_hash'] : $p['xchan_url']); + $ret['id'] = ((strpos($p['xchan_hash'], 'http') === 0) ? $p['xchan_hash'] : $current_url); } if ($p['xchan_addr'] && strpos($p['xchan_addr'], '@')) { $ret['preferredUsername'] = substr($p['xchan_addr'], 0, strpos($p['xchan_addr'], '@')); @@ -1610,7 +1625,7 @@ class Activity 'height' => 300, 'width' => 300, ]; - $ret['url'] = $p['xchan_url']; + $ret['url'] = $current_url; if (isset($p['channel_location']) && $p['channel_location']) { $ret['location'] = ['type' => 'Place', 'name' => $p['channel_location']]; } @@ -1640,8 +1655,8 @@ class Activity $ret['discoverable'] = ((1 - intval($p['xchan_hidden'])) ? true : false); $ret['publicKey'] = [ - 'id' => $p['xchan_url'] . '?operation=getkey', - 'owner' => $p['xchan_url'], + 'id' => $current_url . '?operation=getkey', + 'owner' => $current_url, 'signatureAlgorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', 'publicKeyPem' => $p['xchan_pubkey'] ]; @@ -1730,8 +1745,8 @@ class Activity } } else { $ret['publicKey'] = [ - 'id' => $p['xchan_url'], - 'owner' => $p['xchan_url'], + 'id' => $current_url, + 'owner' => $current_url, 'publicKeyPem' => $p['xchan_pubkey'] ]; } diff --git a/include/conversation.php b/include/conversation.php index b5eda84d1..d28d42a75 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -118,16 +118,20 @@ function localize_item(&$item) return; } - if (isset($obj['author']) && $obj['author'] && $obj['author']['link']) { - $author_link = get_rel_link($obj['author']['link'], 'alternate'); - } else { - $author_link = ''; + if (isset($obj['actor']) && is_string($obj['actor']) && $obj['actor']) { + $author_link = $obj['actor']; + } elseif (isset($obj['attributedTo']) && is_string($obj['attributedTo']) && $obj['attributedTo']) { + $author_link = $obj['attributedTo']; + } + else { + $author_link = EMPTY_STR; } - $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); - - $item_url = get_rel_link($obj['link'], 'alternate'); + $author_name = ((array_path_exists('author/name',$obj) && $obj['author']['name']) ? $obj['author']['name'] : ''); + if (isset($obj['link'])) { + $item_url = get_rel_link($obj['link'], 'alternate'); + } $Bphoto = ''; switch ($obj['type']) { diff --git a/include/items.php b/include/items.php index 9961bbc0b..5cec703d1 100644 --- a/include/items.php +++ b/include/items.php @@ -2439,7 +2439,8 @@ function send_status_notifications($post_id,$item) { $unfollowed = false; $parent = 0; - + $thr_parent_id = 0; + if(array_key_exists('verb',$item) && (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE))) { $r = q("select id from item where mid = '%s' and uid = %d limit 1",