h3poteto / megalodon

Fediverse API client library for node.js and browser
https://h3poteto.github.io/megalodon/
MIT License
250 stars 33 forks source link

Option to GET only public account statuses (GoToSocial) #2210

Closed Ryuno-Ki closed 1 month ago

Ryuno-Ki commented 2 months ago

Amazing project! I love it! My use case is to display my last public toot (not a reply or boost) on my homepage.

I'm almost there! Running my own GoToSocial instance at fedi.jaenis.ch I can study the API: https://docs.gotosocial.org/en/latest/api/swagger/

I can see that there's an only_public flag that I cannot set in Megalodon's implementation.

For now I'm overfetching and filtering the results (status.visibility === "public") on the client. This incurs a little bit more data, which I would like to avoid (because it could mean visitors paying more than strictly necessary).

Is there a way to extend the API here? Or are there constraints (such as: same API for all fedi services)?

h3poteto commented 2 months ago

For example, Mastodon doesn't have such parameter: https://github.com/mastodon/mastodon/blob/8afa3bb2fa872c2413cd264ca3321a7509a5ffdf/app/lib/account_statuses_filter.rb#L3

But, it seems like Gotosocial has it. So, it's not so difficult to implement the parameter in megalodon.

Ryuno-Ki commented 2 months ago

Are you accepting PRs on it? I could take an attempt then.

h3poteto commented 2 months ago

Of course, I'm waiting for your PRs. Thank you.

Ryuno-Ki commented 1 month ago

I've opened #2211 with the change.

Looking at the tests folder I could not see a folder or file for GoToSocial. Therefore no updates there. I tested the changes by changing the files in the node_modules of an existing application and confirmed they're working (better than blindly accepting it, I feel).