From d6c1e85b5fe1a110ece698434e4b2010c16cb2ac Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Thu, 16 Feb 2023 08:05:32 -0500 Subject: [PATCH] Add blocked/ignored filters to Mastodon Timeline API Home and Tags endpoints --- src/Module/Api/Mastodon/Timelines/Home.php | 7 +++++++ src/Module/Api/Mastodon/Timelines/Tag.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index 5efaf4930e..c121bad666 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -90,6 +90,13 @@ class Home extends BaseApi $condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]); } + if (!empty($uid)) { + $condition = DBA::mergeConditions( + $condition, + ["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid] + ); + } + $items = Post::selectForUser($uid, ['uri-id'], $condition, $params); $display_quotes = self::appSupportsQuotes(); diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index 1d04dec625..64cd84366e 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -104,6 +104,13 @@ class Tag extends BaseApi $params['order'] = ['uri-id']; } + if (!empty($uid)) { + $condition = DBA::mergeConditions( + $condition, + ["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid] + ); + } + $items = DBA::select('tag-search-view', ['uri-id'], $condition, $params); $display_quotes = self::appSupportsQuotes();