Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't edit status: wrong verb #1017

Closed
rakoo opened this issue Dec 10, 2023 · 6 comments
Closed

Can't edit status: wrong verb #1017

rakoo opened this issue Dec 10, 2023 · 6 comments

Comments

@rakoo
Copy link

rakoo commented Dec 10, 2023

Hello there, thanks for your library !

I'm using it through phanpy (https://github.com/cheeaun/phanpy) (ping @cheeaun) and I can't edit messages there. Turns out the HTTP verb is not correct: the spec says edits happen through a PUT (https://docs.joinmastodon.org/methods/statuses/#edit) but masto.js uses PATCH (https://github.com/neet/masto.js/blob/main/src/adapters/action/dispatcher-http.ts#L50)

I don't have a reproducer handy but hacking one from the README example shouldn't be too hard

@cheeaun
Copy link

cheeaun commented Dec 11, 2023

Interesting, surprisingly editing works for me with PATCH on hachyderm.io instance, despite not documented there.

@rakoo is your instance Pleroma?

@rakoo
Copy link
Author

rakoo commented Dec 11, 2023

It is pleroma indeed !

@neet
Copy link
Owner

neet commented Dec 11, 2023

Hi @rakoo, thank you for reporting an issue. Unfortunately, this problem is likely to be caused by the Pleroma implementation rather than a bug in Masto.js, since both PATCH and PUT work in the upstream implementation.

This is because Mastodon is built on top of Ruby on Rails where both PATCH and PUT will be mapped to the same update method of the routing controller:
https://edgeguides.rubyonrails.org/routing.html#:~:text=editing%20a%20photo-,PATCH/PUT,-/photos/%3Aid

HTTP Method Procedure to reproduce
PATCH image
PUT image

This is why I believe I can code all methods as PATCH for the consistency. I don't regard the documentation from https://docs.joinmastoodn.org as a "spec" that defines which ones are correct and which ones are not since they simply use PATCH and PUT interchangeably as Rails does.

Due to the limited development resources, we're currently emphasising dedicated support for Mastodon, and not maintaining compatibility for Mastodon forks. I'm planning to introduce a plugin feature to achieve this in the future. #939

@rakoo
Copy link
Author

rakoo commented Dec 11, 2023

Oh ok, but the issue is that this is not documented anywhere when developers are looking at the spec. I specifically chose Pleroma to test the interoperability between implementations, because what defines interoperability and the reason one can talk with another is the spec, not the implementation. Imagine if your web browser never used GET but FETCH instead, but because your server is custom and accepts both you wouldn't see the difference; anyone else would be unable to see your content because they'd use the standard. That's what's happening here.

I disagree that it is an issue with Pleroma, because Pleroma conforms to the spec, and the spec is the document above, not the particular implementation of Rails. The Mastodon API is becoming a standard and for better or for worth it means all microblogging-related software will have to respect it at some point, which is not necessarily the best but it works; what you propose here is not even to adhere to the API but to the particular workings of the software. You say you don't want to support forks which is totally fair, but actually by not adhering to the spec you actively prevent forks from existing, while not making it better for Mastodon. The spec written by Mastodon itself.

If a plugin happens to fix this issue as part of #939, that plugin's name will unfortunately have to be "actually-follow-the-specs". It's not about adding functionalities, or object types, or anything Mastodon doesn't already understand.

But I'll have to accept it because that's your project :)

@neet
Copy link
Owner

neet commented Feb 29, 2024

I decided to follow the official documentation in #1046 as it is taking a time to make the plugin functionality public.

Also, the latest documentation seems to classify all the update methods to PUT except for /api/v1/update_credentials which is supposedly related to OAuth2 spec. I was discussing based on what I read in the past, but it's reasonable enough to comply with it now.

I haven't tested if it actually works on Mastodon forks since I'm still putting the highest priority on Mastodon itself, but I suppose it resolves the issue.

@rakoo
Copy link
Author

rakoo commented Mar 1, 2024

Thanks a lot for this change ! I'll report with my own situation on pleroma when it lands in phanpy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants