From e5d694f7fabd19ab61d3b35f1a1a3556edf66092 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Jan 2019 21:52:43 +0000 Subject: [PATCH 1/4] AP: Only reshare stuff that is AP content --- src/Protocol/ActivityPub/Transmitter.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index be2337ff76..cab0030577 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -548,7 +548,18 @@ class Transmitter */ private static function getTypeOfItem($item) { - if (!empty(Diaspora::isReshare($item['body'], false))) { + $reshared = false; + + // Only check for a reshare, if it is a real reshare and no quoted reshare + if (strpos($item['body'], "[share") === 0) { + $announce = api_share_as_retweet($item); + if (!empty($announce['plink'])) { + $data = ActivityPub::fetchContent($announce['plink'], $item['uid']); + $reshared = !empty($data); + } + } + + if ($reshared) { $type = 'Announce'; } elseif ($item['verb'] == ACTIVITY_POST) { if ($item['created'] == $item['edited']) { @@ -1018,6 +1029,7 @@ class Transmitter return self::createNote($item); } + /// @todo Better fetch the real object url. return $announce['plink']; } From 9e7c59481f8b08ba6acda89904299da9e700c8f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Jan 2019 22:19:53 +0000 Subject: [PATCH 2/4] Improved ID detection --- src/Protocol/ActivityPub/Transmitter.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index cab0030577..671f4279a2 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -1029,8 +1029,17 @@ class Transmitter return self::createNote($item); } - /// @todo Better fetch the real object url. - return $announce['plink']; + // Fetch the original id of the object + $activity = ActivityPub::fetchContent($announce['plink'], $item['uid']); + if (!empty($activity)) { + $ldactivity = JsonLD::compact($activity); + $id = JsonLD::fetchElement($ldactivity, '@id'); + if (!empty($id)) { + return $id; + } + } + + return self::createNote($item); } /** From e2427eb9da8d32c35488b609f79e167786168ecc Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Jan 2019 22:56:33 +0000 Subject: [PATCH 3/4] We only need to fetch the content once --- src/Protocol/ActivityPub/Transmitter.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 671f4279a2..c8285aa35a 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -553,10 +553,7 @@ class Transmitter // Only check for a reshare, if it is a real reshare and no quoted reshare if (strpos($item['body'], "[share") === 0) { $announce = api_share_as_retweet($item); - if (!empty($announce['plink'])) { - $data = ActivityPub::fetchContent($announce['plink'], $item['uid']); - $reshared = !empty($data); - } + $reshared = !empty($announce['plink']); } if ($reshared) { From 70c183b4959fcffcd700d2343be8c3eddcc1e8ef Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 20 Jan 2019 23:13:55 +0000 Subject: [PATCH 4/4] AP Bugfix: We hadn't transmitted an tag url at all ... --- src/Protocol/ActivityPub/Transmitter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index c8285aa35a..89986f4923 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -755,7 +755,8 @@ class Transmitter $terms = Term::tagArrayFromItemId($item['id']); foreach ($terms as $term) { if ($term['type'] == TERM_HASHTAG) { - $tags[] = ['type' => 'Hashtag', 'href' => $term['url'], 'name' => '#' . $term['term']]; + $url = System::baseUrl() . '/search?tag=' . urlencode($term['term']); + $tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['term']]; } elseif ($term['type'] == TERM_MENTION) { $contact = Contact::getDetailsByURL($term['url']); if (!empty($contact['addr'])) {