Merge pull request #10299 from annando/issue-10287

Issue 10287: Make block and ignore work for the API as well
This commit is contained in:
Tobias Diekershoff 2021-05-23 12:03:01 +02:00 committed by GitHub
commit edbbaaadea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,8 @@ class PublicTimeline extends BaseApi
*/ */
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$uid = self::getCurrentUserID();
$request = self::getRequest([ $request = self::getRequest([
'local' => false, // Show only local statuses? Defaults to false. 'local' => false, // Show only local statuses? Defaults to false.
'remote' => false, // Show only remote 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]); $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 = []; $statuses = [];
while ($item = Post::fetch($items)) { while ($item = Post::fetch($items)) {