diff --git a/src/Module/Api/Mastodon/Timelines/Home.php b/src/Module/Api/Mastodon/Timelines/Home.php index c4ca074f4..0c955b1c7 100644 --- a/src/Module/Api/Mastodon/Timelines/Home.php +++ b/src/Module/Api/Mastodon/Timelines/Home.php @@ -43,15 +43,15 @@ class Home extends BaseApi $uid = self::getCurrentUserID(); $request = self::getRequest([ - 'max_id' => 0, // Return results older than id - 'since_id' => 0, // Return results newer than id - 'min_id' => 0, // Return results immediately newer than id - 'limit' => 20, // Maximum number of results to return. Defaults to 20. - 'local' => false, // Return only local statuses? - 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. - 'only_media' => false, // Show only statuses with media attached? Defaults to false. - 'local' => false, // Show only local statuses? Defaults to false. - 'remote' => false, // Show only remote statuses? Defaults to false. + 'max_id' => 0, // Return results older than id + 'since_id' => 0, // Return results newer than id + 'min_id' => 0, // Return results immediately newer than id + 'limit' => 20, // Maximum number of results to return. Defaults to 20. + 'local' => false, // Return only local statuses? + 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'only_media' => false, // Show only statuses with media attached? Defaults to false. + 'remote' => false, // Show only remote statuses? Defaults to false. + 'exclude_replies' => false, // Don't show comments ]); $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; @@ -81,14 +81,14 @@ class Home extends BaseApi Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]); } - if ($request['local']) { - $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); - } - if ($request['remote']) { $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); } + if ($request['exclude_replies']) { + $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]); + } + $items = Post::selectForUser($uid, ['uri-id'], $condition, $params); $statuses = []; diff --git a/src/Module/Api/Mastodon/Timelines/ListTimeline.php b/src/Module/Api/Mastodon/Timelines/ListTimeline.php index 0ff22cba4..e5bf9d76f 100644 --- a/src/Module/Api/Mastodon/Timelines/ListTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/ListTimeline.php @@ -47,14 +47,15 @@ class ListTimeline extends BaseApi } $request = self::getRequest([ - 'max_id' => 0, // Return results older than id - 'since_id' => 0, // Return results newer than id - 'min_id' => 0, // Return results immediately newer than id - 'limit' => 20, // Maximum number of results to return. Defaults to 20.Return results older than this ID. - 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. - 'only_media' => false, // Show only statuses with media attached? Defaults to false. - 'local' => false, // Show only local statuses? Defaults to false. - 'remote' => false, // Show only remote statuses? Defaults to false. + 'max_id' => 0, // Return results older than id + 'since_id' => 0, // Return results newer than id + 'min_id' => 0, // Return results immediately newer than id + 'limit' => 20, // Maximum number of results to return. Defaults to 20.Return results older than this ID. + 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'only_media' => false, // Show only statuses with media attached? Defaults to false. + 'local' => false, // Show only local statuses? Defaults to false. + 'remote' => false, // Show only remote statuses? Defaults to false. + 'exclude_replies' => false, // Don't show comments ]); $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; @@ -81,6 +82,10 @@ class ListTimeline extends BaseApi Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]); } + if ($request['exclude_replies']) { + $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]); + } + if ($request['local']) { $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]); } diff --git a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php index 05f3c7baf..87d0dc1d9 100644 --- a/src/Module/Api/Mastodon/Timelines/PublicTimeline.php +++ b/src/Module/Api/Mastodon/Timelines/PublicTimeline.php @@ -42,14 +42,15 @@ class PublicTimeline extends BaseApi public static function rawContent(array $parameters = []) { $request = self::getRequest([ - 'local' => false, // Show only local statuses? Defaults to false. - 'remote' => false, // Show only remote statuses? Defaults to false. - 'only_media' => false, // Show only statuses with media attached? Defaults to false. - 'max_id' => 0, // Return results older than this id - 'since_id' => 0, // Return results newer than this id - 'min_id' => 0, // Return results immediately newer than this id - 'limit' => 20, // Maximum number of results to return. Defaults to 20. - 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'local' => false, // Show only local statuses? Defaults to false. + 'remote' => false, // Show only remote statuses? Defaults to false. + 'only_media' => false, // Show only statuses with media attached? Defaults to false. + 'max_id' => 0, // Return results older than this id + 'since_id' => 0, // Return results newer than this id + 'min_id' => 0, // Return results immediately newer than this id + 'limit' => 20, // Maximum number of results to return. Defaults to 20. + 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'exclude_replies' => false, // Don't show comments ]); $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; @@ -83,6 +84,10 @@ class PublicTimeline extends BaseApi $params['order'] = ['uri-id']; } + if ($request['exclude_replies']) { + $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]); + } + $items = Post::selectForUser(0, ['uri-id', 'uid'], $condition, $params); $statuses = []; diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index e33923dfd..efcab825a 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -48,14 +48,15 @@ class Tag extends BaseApi } $request = self::getRequest([ - 'local' => false, // If true, return only local statuses. Defaults to false. - 'remote' => false, // Show only remote statuses? Defaults to false. - 'only_media' => false, // If true, return only statuses with media attachments. Defaults to false. - 'max_id' => 0, // Return results older than this ID. - 'since_id' => 0, // Return results newer than this ID. - 'min_id' => 0, // Return results immediately newer than this ID. - 'limit' => 20, // Maximum number of results to return. Defaults to 20. - 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'local' => false, // If true, return only local statuses. Defaults to false. + 'remote' => false, // Show only remote statuses? Defaults to false. + 'only_media' => false, // If true, return only statuses with media attachments. Defaults to false. + 'max_id' => 0, // Return results older than this ID. + 'since_id' => 0, // Return results newer than this ID. + 'min_id' => 0, // Return results immediately newer than this ID. + 'limit' => 20, // Maximum number of results to return. Defaults to 20. + 'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users. + 'exclude_replies' => false, // Don't show comments ]); $params = ['order' => ['uri-id' => true], 'limit' => $request['limit']]; @@ -77,6 +78,10 @@ class Tag extends BaseApi Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]); } + if ($request['exclude_replies']) { + $condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]); + } + if (!empty($request['max_id'])) { $condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]); }