superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.61k stars 304 forks source link

Mastodon API deviation #1034

Closed anantshri closed 1 year ago

anantshri commented 1 year ago

Describe the bug with a clear and concise description of what the bug is.

Thanks for the tool.

I was testing the tool for compatibility with toot cli and realized althought auth related issue https://github.com/superseriousbusiness/gotosocial/issues/192 were resolved.

there is another change / deviation i observed

Mastodon search api v2 : https://docs.joinmastodon.org/methods/search/ is what we have implemented as v1 : in https://github.com/superseriousbusiness/gotosocial/blob/main/docs/api/swagger.yaml#L3671 also visible https://docs.gotosocial.org/en/latest/api/swagger/

This is breaking the toot follow command as follow needs to search first.

What's your GoToSocial Version?

0.5.2

GoToSocial Arch

amd64 binary

Browser version

No response

What happened?

when trying to follow via toot cli we get error on debug e get simmilar message

$ toot follow --debug '<USERNAME>@<HOST_DOMAIN>'
DEBUG:toot:>>> GET https://<INSTANCE_ADDRESS>/api/v1/accounts/search
DEBUG:toot:>>> HEADERS: {('User-Agent', 'toot/0.28.0'), ('Authorization', '***CENSORED***')}
DEBUG:toot:>>> PARAMS:  {'q': '<USERNAME>@<HOST_DOMAIN>'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): <INSTANCE_ADDRESS>:443
DEBUG:urllib3.connectionpool:https://<INSTANCE_ADDRESS>:443 "GET /api/v1/accounts/search?q=<USERNAME>%40<HOST_DOMAIN> HTTP/1.1" 404 655
DEBUG:toot:<<< <Response [404]>
DEBUG:toot:<<< b'<!DOCTYPE html>\n\n\n<html lang="en">\n<head>\n\t<meta charset="UTF-8">\n\t<meta http-equiv="X-UA-Compatible" content="IE=edge">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<link rel="shortcut icon" href="/assets/logo.png" type="image/png">\n\t<link rel="stylesheet" href="/assets/dist/_colors.css">\n\t<link rel="stylesheet" href="/assets/dist/base.css">\n\t<title>Anant&#39;s Social Feed - GoToSocial</title>\n</head>\n<body>\n\t<div class="page">\n\t\t<header>\n\t\t\t<a aria-label="instance homepage" href="/" class="nounderline header">\n\t\t\t\t<img src="/assets/logo.png" alt="Instance Logo"/>\n\t\t\t\t<div>\n\t\t\t\t\t<h1>\n\t\t\t\t\t\t\n\t\t\t\t\t</h1>\n\t\t\t\t</div>\n\t\t\t</a>\n\t\t</header>\n\t\t<div class="content">\n\n<main>\n\t<section>\n\t\t<h1>404: Page Not Found</h1>\n\t\t<p>\n\t\t\tGoToSocial only serves Public statuses via the web.\n\t\t\tIf you reached this page by clicking on a status link,\n\t\t\tit\'s possible that the status is not Public, has been\n\t\t\tdeleted by the author, you don\'t have permission to see\n\t\t\tit, or it just doesn\'t exist at all.\n\t\t</p>\n\t\t<p>\n\t\t\tIf you believe this 404 was an error, you can contact\n\t\t\tthe instance admin.\n\t\t</p>\n\t</section>\n</main>\n\n\t\t\n\t\t</div>\n\t\t<footer>\n\t\t</footer>\n\t</div>\n\t\n</body>\n</html>\n'
Unknown error

What you expected to happen?

Toot cli was suppose to follow the user

How to reproduce it?

do a toot auth and then toot follow command

Anything else we need to know?

a stated above this is a api compatability issue

Mastodon search api v2 : https://docs.joinmastodon.org/methods/search/ is what we have implemented as v1 : in https://github.com/superseriousbusiness/gotosocial/blob/main/docs/api/swagger.yaml#L3671 also visible https://docs.gotosocial.org/en/latest/api/swagger/

anantshri commented 1 year ago

As of now I am using https://github.com/anantshri/gotosocial_bulk_follow code to do the action but would love to have proper api compatibility.

tsmethurst commented 1 year ago

Judging from the logs, it looks like the issue is that we just haven't implemented /api/v1/accounts/search yet, as opposed to /api/v1/search, which we have implemented.

anantshri commented 1 year ago

I might be misled but i think i got confused with https://github.com/ihabunek/toot/commit/89585b6761769d2b0e3410ac714d12d91a9c24a6 where toot cli changed search api from v1 to v2 and in v1 /accounts existed where as for v2 its directly search.

In gotosocial we have /search without account which matches with v2 specs just that v2 is not specified.

Tootcli has just released a new version will update comments with status updated regarding this new version.

anantshri commented 1 year ago

Ah this is interesting. I didnt explored this properly it seems. so yes /api/v1/accounts/search is not implemented but we do have /api/v1/search and /api/v2/search already implemented with https://github.com/ihabunek/toot/releases/tag/0.28.1 i am able to use toot cli follow command properly with gotosocial.

Closing the issue as my concern is sorted.