fix: disallow media description exceeding limits #1854
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mastodon enforces a 1500 character limit on media attachment descriptions. This is visible in their interface too:
Elk on the other hand has no such indicator:
As such, it enforces no limits on the attachment length, and so if you post something exceeding 1500 characters, you get this in your console:
This error is not visible to the user (due to it not being captured in
failedMessages
since the error occurs insetDescription
(publish.ts
) which has no access to that array)In any case, the potential solutions to this issue would be as follows:
I chose to go with the latter solution, since the first one was a bit difficult to implement given the current architecture of the code.
So with this PR, one would see this after entering too many characters:
Additionally, since this PR prevents setting long descriptions (i.e. disables the button), I figured I'd also include that inside the status submission ("Publish") button, since that effectively prevents the user from calling an unnecessary API request that will always fail, and will always throw an error message to the user. So long statuses won't be publishable:
(Perhaps not the most elegant solution -- disabled button does not look the greatest, and I had to make a simple character component just to avoid code duplication -- but it works)
Fixes #1018.