From 8ab7e6552ba40bac2199cc105d286bdc3ed434f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2023 13:05:59 +0000 Subject: [PATCH] Improved fetching of attached activities --- src/Factory/Api/Mastodon/Status.php | 9 +++++++-- src/Model/Item.php | 7 ++++++- src/Module/Media/Photo/Upload.php | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index c331590b5..3973690c0 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -323,8 +323,13 @@ class Status extends BaseFactory { if (empty($item['quote-uri-id'])) { $media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]); - if (!empty($media) && $shared_item = Post::selectFirst(['uri-id'], ['plink' => $media[0]['url'], 'uid' => [$uid, 0]])) { - $quote_id = $shared_item['uri-id']; + if (!empty($media)) { + if (!empty($media['media-uri-id'])) { + $quote_id = $media['media-uri-id']; + } else { + $shared_item = Post::selectFirst(['uri-id'], ['plink' => $media[0]['url'], 'uid' => [$uid, 0]]); + $quote_id = $shared_item['uri-id'] ?? 0; + } } } else { $quote_id = $item['quote-uri-id']; diff --git a/src/Model/Item.php b/src/Model/Item.php index 8479c1a6d..a730404ed 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3044,7 +3044,12 @@ class Item } elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id']) && ($item['network'] != Protocol::DIASPORA)) { $media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]); if (!empty($media)) { - $shared_item = Post::selectFirst($fields, ['plink' => $media[0]['url'], 'uid' => [$item['uid'], 0]]); + $shared_item = Post::selectFirst($fields, ['uri-id' => $media[0]['media-uri-id'], 'uid' => [$item['uid'], 0]]); + if (empty($shared_item['uri-id'])) { + $shared_item = Post::selectFirst($fields, ['plink' => $media[0]['url'], 'uid' => [$item['uid'], 0]]); + } elseif (strtolower($shared['post']['uri']) != strtolower($media[0]['url'])) { + $shared_links[] = strtolower($media[0]['url']); + } if (empty($shared_item['uri-id'])) { $shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]); diff --git a/src/Module/Media/Photo/Upload.php b/src/Module/Media/Photo/Upload.php index 1283b7cf3..988fd652e 100644 --- a/src/Module/Media/Photo/Upload.php +++ b/src/Module/Media/Photo/Upload.php @@ -222,7 +222,7 @@ class Upload extends \Friendica\BaseModule } $this->logger->info('upload done'); - $this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img]' . $this->baseUrl . "/photo/$resource_id-$smallest." . $image->getExt() . "[/img][/url]\n\n"); + $this->return(200, "\n\n" . '[url=' . $this->baseUrl . '/photos/' . $owner['nickname'] . '/image/' . $resource_id . '][img=' . $this->baseUrl . "/photo/$resource_id-$smallest." . $image->getExt() . "][/img][/url]\n\n"); } /**