From dc9b5df072d3155943c32d892af15383a6abcc2d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Jun 2021 04:44:12 +0000 Subject: [PATCH 1/2] API: The endpoints "followers" and "following" are swapped --- src/Module/Api/Mastodon/Accounts/Followers.php | 16 ++++++++-------- src/Module/Api/Mastodon/Accounts/Following.php | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Module/Api/Mastodon/Accounts/Followers.php b/src/Module/Api/Mastodon/Accounts/Followers.php index 65bb3d75f..c311b693e 100644 --- a/src/Module/Api/Mastodon/Accounts/Followers.php +++ b/src/Module/Api/Mastodon/Accounts/Followers.php @@ -54,30 +54,30 @@ class Followers extends BaseApi $request = self::getRequest([ 'max_id' => 0, // Return results older than this id 'since_id' => 0, // Return results newer than this id - 'limit' => 20, // Maximum number of results to return. Defaults to 20. + 'limit' => 40, // Maximum number of results to return. Defaults to 40. ]); - $params = ['order' => ['cid' => true], 'limit' => $request['limit']]; + $params = ['order' => ['relation-cid' => true], 'limit' => $request['limit']]; - $condition = ['relation-cid' => $id, 'follows' => true]; + $condition = ['cid' => $id, 'follows' => true]; if (!empty($request['max_id'])) { - $condition = DBA::mergeConditions($condition, ["`cid` < ?", $request['max_id']]); + $condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $request['max_id']]); } if (!empty($request['since_id'])) { - $condition = DBA::mergeConditions($condition, ["`cid` > ?", $request['since_id']]); + $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['since_id']]); } if (!empty($min_id)) { - $condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]); + $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]); $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['cid'], $condition, $parameters); + $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters); while ($follower = DBA::fetch($followers)) { - $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); + $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid); } DBA::close($followers); diff --git a/src/Module/Api/Mastodon/Accounts/Following.php b/src/Module/Api/Mastodon/Accounts/Following.php index 42b9da4b4..53908b36b 100644 --- a/src/Module/Api/Mastodon/Accounts/Following.php +++ b/src/Module/Api/Mastodon/Accounts/Following.php @@ -57,27 +57,27 @@ class Following extends BaseApi 'limit' => 40, // Maximum number of results to return. Defaults to 40. ]); - $params = ['order' => ['relation-cid' => true], 'limit' => $request['limit']]; + $params = ['order' => ['cid' => true], 'limit' => $request['limit']]; - $condition = ['cid' => $id, 'follows' => true]; + $condition = ['relation-cid' => $id, 'follows' => true]; if (!empty($request['max_id'])) { - $condition = DBA::mergeConditions($condition, ["`relation-cid` < ?", $request['max_id']]); + $condition = DBA::mergeConditions($condition, ["`cid` < ?", $request['max_id']]); } if (!empty($request['since_id'])) { - $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $request['since_id']]); + $condition = DBA::mergeConditions($condition, ["`cid` > ?", $request['since_id']]); } if (!empty($min_id)) { - $condition = DBA::mergeConditions($condition, ["`relation-cid` > ?", $min_id]); + $condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]); $params['order'] = ['cid']; } - $followers = DBA::select('contact-relation', ['relation-cid'], $condition, $parameters); + $followers = DBA::select('contact-relation', ['cid'], $condition, $parameters); while ($follower = DBA::fetch($followers)) { - $accounts[] = DI::mstdnAccount()->createFromContactId($follower['relation-cid'], $uid); + $accounts[] = DI::mstdnAccount()->createFromContactId($follower['cid'], $uid); } DBA::close($followers); From 8e12c1d39be91d58ef4ee5748de127f5ac865e2a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 7 Jun 2021 07:45:20 +0000 Subject: [PATCH 2/2] Added note about missing parameters --- src/Module/Api/Mastodon/Timelines/Tag.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Module/Api/Mastodon/Timelines/Tag.php b/src/Module/Api/Mastodon/Timelines/Tag.php index efcab825a..74a5bb901 100644 --- a/src/Module/Api/Mastodon/Timelines/Tag.php +++ b/src/Module/Api/Mastodon/Timelines/Tag.php @@ -47,6 +47,13 @@ class Tag extends BaseApi DI::mstdnError()->UnprocessableEntity(); } + /** + * @todo Respect missing parameters + * @see https://github.com/tootsuite/mastodon/blob/main/app/controllers/api/v1/timelines/tag_controller.rb + * + * There seem to be the parameters "any", "all", and "none". + */ + $request = self::getRequest([ 'local' => false, // If true, return only local statuses. Defaults to false. 'remote' => false, // Show only remote statuses? Defaults to false.