From 8f9033633cfe36fa760c7147c8dca9b7cd287868 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 May 2021 08:56:24 +0000 Subject: [PATCH] Issue 10287: Make block and ignore work for the API as well --- src/Module/Api/Mastodon/Timelines/PublicTimeline.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php index 87d0dc1d96..113a5cac2e 100644 --- a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php @@ -41,6 +41,8 @@ class PublicTimeline extends BaseApi */ public static function rawContent(array $parameters = []) { + $uid = self::getCurrentUserID(); + $request = self::getRequest([ 'local' => false, // Show only local statuses? Defaults to false. 'remote' => false, // Show only remote statuses? Defaults to false. @@ -88,7 +90,12 @@ class PublicTimeline extends BaseApi $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]); } - $items = Post::selectForUser(0, ['uri-id', 'uid'], $condition, $params); + if (!empty($uid)) { + $condition = DBA::mergeConditions($condition, + ["NOT EXISTS (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `parent-author-id` AND (`blocked` OR `ignored`))", $uid]); + } + + $items = Post::selectForUser($uid, ['uri-id', 'uid'], $condition, $params); $statuses = []; while ($item = Post::fetch($items)) {