From 8d9e0b4eaec2bfb9629cd75d34cd777709d03b2f Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Fri, 26 May 2023 21:37:08 -0400 Subject: [PATCH 1/6] Fix Mastodon API Reshared statuses are a stub w/content in reblog field --- src/Object/Api/Mastodon/Status.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Object/Api/Mastodon/Status.php b/src/Object/Api/Mastodon/Status.php index 0a02a48549..122e62f9ca 100644 --- a/src/Object/Api/Mastodon/Status.php +++ b/src/Object/Api/Mastodon/Status.php @@ -109,6 +109,7 @@ class Status extends BaseDataTransferObject */ public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null) { + $reblogged = !empty($reblog); $this->id = (string)$item['uri-id']; $this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON); $this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON); @@ -135,26 +136,26 @@ class Status extends BaseDataTransferObject $this->uri = $item['uri']; $this->url = $item['plink'] ?? null; - $this->replies_count = $counts->replies; - $this->reblogs_count = $counts->reblogs; - $this->favourites_count = $counts->favourites; + $this->replies_count = $reblogged ? 0 : $counts->replies; + $this->reblogs_count = $reblogged ? 0 : $counts->reblogs; + $this->favourites_count = $reblogged ? 0 : $counts->favourites; $this->favourited = $userAttributes->favourited; $this->reblogged = $userAttributes->reblogged; $this->muted = $userAttributes->muted; $this->bookmarked = $userAttributes->bookmarked; $this->pinned = $userAttributes->pinned; - $this->content = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API); + $this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API); $this->reblog = $reblog; $this->quote = $quote; $this->application = $application->toArray(); $this->account = $account->toArray(); - $this->media_attachments = $attachments; - $this->mentions = $mentions; - $this->tags = $tags; - $this->emojis = []; - $this->card = $card->toArray() ?: null; - $this->poll = $poll; - $this->friendica = $friendica; + $this->media_attachments = $reblogged ? [] : $attachments; + $this->mentions = $reblogged ? [] : $mentions; + $this->tags = $reblogged ? [] : $tags; + $this->emojis = $reblogged ? [] : []; + $this->card = $reblogged ? null : ($card->toArray() ?: null); + $this->poll = $reblogged ? null : $poll; + $this->friendica = $reblogged ? null : $friendica; } /** From 532a46d1886f431efb159818d5afa709b501f261 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Mon, 29 May 2023 14:03:16 -0400 Subject: [PATCH 2/6] Change selectOriginal post to return earliest post from non-0 user I believe the earliest entry not being uid=0 should be the original post of a reshared post --- src/Model/Post.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Model/Post.php b/src/Model/Post.php index 770ab08317..9e137ae379 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -263,7 +263,10 @@ class Post return $result; } - return self::selectFirst($original_fields, ['uri-id' => $result['thr-parent-id'], 'uid' => [0, $result['uid']]], $params); + $final_query_condition = ['uri-id' => $result['thr-parent-id']]; + $final_query_condition = DBA::mergeConditions($final_query_condition, ['uid != 0']); + $final_params = ['order' => ['id']]; + return self::selectFirst($original_fields, $final_query_condition, $final_params); } /** From 7a556d15886bbebd6c1d2019bf8e840e80c8afc0 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Fri, 16 Jun 2023 14:48:12 -0400 Subject: [PATCH 3/6] Fix Mastodon API fav/unfav temporarily by checking if blog in post func --- src/Module/Api/Mastodon/Statuses/Favourite.php | 7 +++++-- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index d1a68862ca..2e51591756 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -42,13 +42,16 @@ class Favourite extends BaseApi DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectOriginalForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'like', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index a3760b4544..d95d9e09c0 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -42,13 +42,16 @@ class Unfavourite extends BaseApi DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectOriginalForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } Item::performActivity($item['id'], 'unlike', $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } From b0fe1927d59b5d7fbc5c293c0356af9b2f966b30 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Fri, 16 Jun 2023 15:31:39 -0400 Subject: [PATCH 4/6] Fix Mastodon API bookmark, mute, pin, reblog EPs temporarily by checking if blog in post func --- src/Module/Api/Mastodon/Statuses/Bookmark.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Mute.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Pin.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Reblog.php | 7 +++++-- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Unmute.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Unpin.php | 5 ++++- src/Module/Api/Mastodon/Statuses/Unreblog.php | 7 +++++-- 8 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 59c61f9913..9625b5e122 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -65,6 +65,9 @@ class Bookmark extends BaseApi Item::update(['starred' => true], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 1f00d39d0e..587999bad7 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -53,6 +53,9 @@ class Mute extends BaseApi Post\ThreadUser::setIgnored($item['uri-id'], $uid, true); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 33a0116eb1..601f82f2d0 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -48,6 +48,9 @@ class Pin extends BaseApi Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index f1922d7271..409f8e788f 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -45,7 +45,7 @@ class Reblog extends BaseApi DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectOriginalForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -58,6 +58,9 @@ class Reblog extends BaseApi Item::performActivity($item['id'], 'announce', $uid); } - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index f95fd9445d..03a3e6f002 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -65,6 +65,9 @@ class Unbookmark extends BaseApi Item::update(['starred' => false], ['id' => $item['id']]); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 2285422cac..63cd6d722d 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -53,6 +53,9 @@ class Unmute extends BaseApi Post\ThreadUser::setIgnored($item['uri-id'], $uid, false); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index c80582d15a..22610f4468 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -48,6 +48,9 @@ class Unpin extends BaseApi Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid); - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index 54a18823a7..a1544807f1 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -44,7 +44,7 @@ class Unreblog extends BaseApi DI::mstdnError()->UnprocessableEntity(); } - $item = Post::selectOriginalForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); + $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); if (!DBA::isResult($item)) { DI::mstdnError()->RecordNotFound(); } @@ -64,6 +64,9 @@ class Unreblog extends BaseApi Item::performActivity($item['id'], 'unannounce', $uid); } - System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray()); + // @TODO Remove once mstdnStatus()->createFromUriId is fixed + $isReblog = $item['uri-id'] != $this->parameters['id']; + + System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); } } From 0985ddb3ff76d24d8e157b7b41d86a5c98ed297a Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 15 Aug 2023 15:23:31 -0400 Subject: [PATCH 5/6] Add PR and Issue Numbers for TODO for createFromUriId hack in Mastodon API --- src/Module/Api/Mastodon/Statuses/Bookmark.php | 4 +++- src/Module/Api/Mastodon/Statuses/Favourite.php | 4 +++- src/Module/Api/Mastodon/Statuses/Mute.php | 4 +++- src/Module/Api/Mastodon/Statuses/Pin.php | 4 +++- src/Module/Api/Mastodon/Statuses/Reblog.php | 4 +++- src/Module/Api/Mastodon/Statuses/Unbookmark.php | 4 +++- src/Module/Api/Mastodon/Statuses/Unfavourite.php | 4 +++- src/Module/Api/Mastodon/Statuses/Unmute.php | 4 +++- src/Module/Api/Mastodon/Statuses/Unpin.php | 4 +++- src/Module/Api/Mastodon/Statuses/Unreblog.php | 4 +++- 10 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Module/Api/Mastodon/Statuses/Bookmark.php b/src/Module/Api/Mastodon/Statuses/Bookmark.php index 9625b5e122..7f32c9a43c 100644 --- a/src/Module/Api/Mastodon/Statuses/Bookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Bookmark.php @@ -65,7 +65,9 @@ class Bookmark extends BaseApi Item::update(['starred' => true], ['id' => $item['id']]); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Favourite.php b/src/Module/Api/Mastodon/Statuses/Favourite.php index 2e51591756..3543a3ba8f 100644 --- a/src/Module/Api/Mastodon/Statuses/Favourite.php +++ b/src/Module/Api/Mastodon/Statuses/Favourite.php @@ -49,7 +49,9 @@ class Favourite extends BaseApi Item::performActivity($item['id'], 'like', $uid); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Mute.php b/src/Module/Api/Mastodon/Statuses/Mute.php index 587999bad7..a99cd68635 100644 --- a/src/Module/Api/Mastodon/Statuses/Mute.php +++ b/src/Module/Api/Mastodon/Statuses/Mute.php @@ -53,7 +53,9 @@ class Mute extends BaseApi Post\ThreadUser::setIgnored($item['uri-id'], $uid, true); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Pin.php b/src/Module/Api/Mastodon/Statuses/Pin.php index 601f82f2d0..5d9a181135 100644 --- a/src/Module/Api/Mastodon/Statuses/Pin.php +++ b/src/Module/Api/Mastodon/Statuses/Pin.php @@ -48,7 +48,9 @@ class Pin extends BaseApi Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Reblog.php b/src/Module/Api/Mastodon/Statuses/Reblog.php index 409f8e788f..98cbd417d0 100644 --- a/src/Module/Api/Mastodon/Statuses/Reblog.php +++ b/src/Module/Api/Mastodon/Statuses/Reblog.php @@ -58,7 +58,9 @@ class Reblog extends BaseApi Item::performActivity($item['id'], 'announce', $uid); } - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Unbookmark.php b/src/Module/Api/Mastodon/Statuses/Unbookmark.php index 03a3e6f002..556db2b4b3 100644 --- a/src/Module/Api/Mastodon/Statuses/Unbookmark.php +++ b/src/Module/Api/Mastodon/Statuses/Unbookmark.php @@ -65,7 +65,9 @@ class Unbookmark extends BaseApi Item::update(['starred' => false], ['id' => $item['id']]); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Unfavourite.php b/src/Module/Api/Mastodon/Statuses/Unfavourite.php index d95d9e09c0..99358be55a 100644 --- a/src/Module/Api/Mastodon/Statuses/Unfavourite.php +++ b/src/Module/Api/Mastodon/Statuses/Unfavourite.php @@ -49,7 +49,9 @@ class Unfavourite extends BaseApi Item::performActivity($item['id'], 'unlike', $uid); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Unmute.php b/src/Module/Api/Mastodon/Statuses/Unmute.php index 63cd6d722d..b6d9c2b195 100644 --- a/src/Module/Api/Mastodon/Statuses/Unmute.php +++ b/src/Module/Api/Mastodon/Statuses/Unmute.php @@ -53,7 +53,9 @@ class Unmute extends BaseApi Post\ThreadUser::setIgnored($item['uri-id'], $uid, false); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Unpin.php b/src/Module/Api/Mastodon/Statuses/Unpin.php index 22610f4468..75b1d6fa5f 100644 --- a/src/Module/Api/Mastodon/Statuses/Unpin.php +++ b/src/Module/Api/Mastodon/Statuses/Unpin.php @@ -48,7 +48,9 @@ class Unpin extends BaseApi Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid); - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); diff --git a/src/Module/Api/Mastodon/Statuses/Unreblog.php b/src/Module/Api/Mastodon/Statuses/Unreblog.php index a1544807f1..6730e0fb56 100644 --- a/src/Module/Api/Mastodon/Statuses/Unreblog.php +++ b/src/Module/Api/Mastodon/Statuses/Unreblog.php @@ -64,7 +64,9 @@ class Unreblog extends BaseApi Item::performActivity($item['id'], 'unannounce', $uid); } - // @TODO Remove once mstdnStatus()->createFromUriId is fixed + // @TODO Remove once mstdnStatus()->createFromUriId is fixed so that it returns posts not reshared posts if given an ID to an original post that has been reshared + // Introduced in this PR: https://github.com/friendica/friendica/pull/13175 + // Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350 $isReblog = $item['uri-id'] != $this->parameters['id']; System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray()); From ba967386f4f2c1d5977f1ac4ac4473ad892e366b Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Wed, 16 Aug 2023 14:37:24 -0400 Subject: [PATCH 6/6] Revert Post::selectOriginal to original logic --- src/Model/Post.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Model/Post.php b/src/Model/Post.php index 9e137ae379..770ab08317 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -263,10 +263,7 @@ class Post return $result; } - $final_query_condition = ['uri-id' => $result['thr-parent-id']]; - $final_query_condition = DBA::mergeConditions($final_query_condition, ['uid != 0']); - $final_params = ['order' => ['id']]; - return self::selectFirst($original_fields, $final_query_condition, $final_params); + return self::selectFirst($original_fields, ['uri-id' => $result['thr-parent-id'], 'uid' => [0, $result['uid']]], $params); } /**