Improved fetching of attached activities

This commit is contained in:
Michael 2023-05-01 13:05:59 +00:00
parent d425f2eaac
commit 8ab7e6552b
3 changed files with 14 additions and 4 deletions

View file

@ -323,8 +323,13 @@ class Status extends BaseFactory
{ {
if (empty($item['quote-uri-id'])) { if (empty($item['quote-uri-id'])) {
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]); $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]])) { if (!empty($media)) {
$quote_id = $shared_item['uri-id']; 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 { } else {
$quote_id = $item['quote-uri-id']; $quote_id = $item['quote-uri-id'];

View file

@ -3044,7 +3044,12 @@ class Item
} elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id']) && ($item['network'] != Protocol::DIASPORA)) { } 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]); $media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]);
if (!empty($media)) { 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'])) { if (empty($shared_item['uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]); $shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);

View file

@ -222,7 +222,7 @@ class Upload extends \Friendica\BaseModule
} }
$this->logger->info('upload done'); $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");
} }
/** /**