From a4515daca4980377c56cd12d56a12cf505dc57bf Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Thu, 16 Feb 2023 08:08:58 -0500 Subject: [PATCH] Add blocked/ignored filters to Mastodon Timeline API Direct and List endpoints --- src/Module/Api/Mastodon/Timelines/Direct.php | 7 +++++++ src/Module/Api/Mastodon/Timelines/ListTimeline.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Module/Api/Mastodon/Timelines/Direct.php b/src/Module/Api/Mastodon/Timelines/Direct.php index a5f1f97f32..82b96e698f 100644 --- a/src/Module/Api/Mastodon/Timelines/Direct.php +++ b/src/Module/Api/Mastodon/Timelines/Direct.php @@ -65,6 +65,13 @@ class Direct 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] + ); + } + $mails = DBA::select('mail', ['id', 'uri-id'], $condition, $params); $statuses = []; diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index a8de13056e..378e3eeaaf 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -95,6 +95,13 @@ class ListTimeline extends BaseApi $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin` AND `post-user`.`uri-id` = `post-user-view`.`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 = Post::selectForUser($uid, ['uri-id'], $condition, $params); $display_quotes = self::appSupportsQuotes();