glacasa / Mastonet

C# Library for Mastodon
MIT License
225 stars 36 forks source link

Issues with media attachment uploads after upgrade to v3 of the client #119

Open 13xforever opened 9 months ago

13xforever commented 9 months ago

After upgrading from v2 to v3 I started to get exceptions like this:

Mastonet.ServerErrorException: Cannot attach files that have not finished processing. Try again in a moment!
   at Mastonet.BaseHttpClient.TryDeserialize[T](String json)
   at Mastonet.BaseHttpClient.Post[T](String route, IEnumerable`1 data, IEnumerable`1 media)
   at MeduzaRepost.MastodonWriter.TryToHandle(TgEvent evt) in /home/13xforever/meduza-bot/MeduzaRepost/Mastodon/MastodonWriter.cs:line 142

Looking for existing issues, I've seen #116 requesting support for async attachment uploads.

I'm not expert on Mastodon APIs, but as far as I understand, what happened is that mastonet library has moved from the synchronous obsolete API call v1 to the new asynchronous API v2 between v2 and v3 of the client (that's a speculation on my part).

Part of the async API is the ability to get media upload status/info meta, which is not implemented/exposed in mastonet client v3. As part of the GET call, Mastodon provides the ability to check media processing status (chiefly for video reencoding, but they're moving to async processing of all media if you look at the version history).

This is an issue because Mastodon does not allow posting new status with media attachments that have not finished processing yet, as evident by the returned error.

So, from my understanding, what we need is 1. exposing the GET API call for media attachments, and 2. as proposed in #116, to optionally provide a convenience method to wait for media processing to be complete