Doubling the backoff every iteration turned out to be a bit
too relaxed for the common situations where you run into API
throttling. This change gives the API enough room to breathe,
but re-tries requests just a little more often.
Mastodon API's pagination IDs are not guaranteed to be in a numeric format.
This happens to be the case for the tootsuite implementation, but others
use UUIDs or flake IDs for pagination.
This also simplifies the code a bit and luckily shouldn't break backwards
compatibility since they're already of type ID in the Pagination struct.
Since it's difficult to wrap all possible go-mastodon API calls in a backoff
algorithm outside of the package itself, I decided to implement a simple
version of it in go-mastodon's doAPI itself.
This works nicely, but could be improved in two ways still:
- Abort sleeping when context gets cancelled
- Make backoff optional / configurable
Personally, I still think this is a good start and probably fits most of
go-mastodon's use-cases. It certainly beats string-grepping for status code
"429" in clients.
Added missing fields to various structs and sorted them in the same order as
the original mastodon API documentation does. This should make it easier to
compare go-mastodon's structs with the original documentation.
This is required for users who have 2-factor authentication enabled, and is generally safer because users don't need to give their password to third-party software.
`doAPI`'s `context` does not work due to `WithContext` immutability.
`Authenticate` and `RegisterApp` does not use `context` although they
needs `context`, so their `context` does not work also. This commit fixes
them and add test cases.