From 64fd94fc7402ef1f369dde113f7186319d349205 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 2 Sep 2021 05:57:50 +0000 Subject: [PATCH] Issue 10651: remote comments appeared as own posts --- src/Module/Diaspora/Fetch.php | 10 ++++++++-- src/Protocol/Diaspora.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Module/Diaspora/Fetch.php b/src/Module/Diaspora/Fetch.php index 17f664baf8..ff4a3ac8da 100644 --- a/src/Module/Diaspora/Fetch.php +++ b/src/Module/Diaspora/Fetch.php @@ -51,7 +51,8 @@ class Fetch extends BaseModule 'uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'received', 'app', 'location', 'coord', 'network', 'event-id', 'resource-id', 'author-link', 'author-avatar', 'author-name', 'plink', 'owner-link', 'uri-id' ]; - $condition = ['wall' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; + $condition = ['origin' => true, 'private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $guid, + 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; $item = Post::selectFirst($fields, $condition); if (empty($item)) { $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]]; @@ -78,7 +79,12 @@ class Fetch extends BaseModule throw new HTTPException\NotFoundException(); } - $status = Diaspora::buildStatus($item, $user); + if ($item['gravity'] == GRAVITY_PARENT) { + $status = Diaspora::buildStatus($item, $user); + } else { + $status = Diaspora::constructComment($item, $user); + } + $xml = Diaspora::buildPostXml($status["type"], $status["message"]); // Send the envelope diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 48d7a3371c..f4dc997e62 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3614,7 +3614,7 @@ class Diaspora * @return array|false The data for a comment * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - private static function constructComment(array $item, array $owner) + public static function constructComment(array $item, array $owner) { $cachekey = "diaspora:constructComment:".$item['guid'];