Skip to content

Conversation

@mkrasnitski
Copy link
Collaborator

Back in September 2024, Discord added Soundboard APIs that allow a bot to create a new sound by uploading raw mp3 or ogg data. This data is specified as part of the JSON rather than a multipart upload (an odd decision IMO), however that means that the semantics of ImageData are wrong as it makes too many assumptions about its contents. In particular, we assume that the base64 data will always be an image, and the CreateAttachment::encode method always assigns the image/png mimetype.

This PR removes these assumptions by renaming the struct to simply DataUri, and now requiring the user to specify the mimetype when calling CreateAttachment::encode.

@github-actions github-actions bot added model Related to the `model` module. builder Related to the `builder` module. labels Aug 29, 2025
@arqunis arqunis added enhancement An improvement to Serenity. breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users labels Aug 29, 2025
@mkrasnitski
Copy link
Collaborator Author

I somehow forgot we already had support for the soundboard API.

@arqunis arqunis merged commit b6d81d9 into serenity-rs:next Sep 4, 2025
24 checks passed
@mkrasnitski mkrasnitski deleted the data-uri branch September 5, 2025 03:26
BossFlea pushed a commit to BossFlea/serenity that referenced this pull request Sep 16, 2025
…ity-rs#3412)

Back in September 2024, Discord added [Soundboard][soundboard] APIs that allow
a bot to create a new sound by uploading raw mp3 or ogg data.

This data is specified as part of the JSON rather than a multipart upload (an
odd decision IMO); however, that means that the semantics of `ImageData` are
wrong as it makes too many assumptions about its contents. In particular, we
assume that the base64 data will always be an image, and the
`CreateAttachment::encode` method always assigns the `image/png` mimetype.

This commit removes these assumptions by renaming the struct to simply
`DataUri`, and now requiring the user to specify the mimetype when calling
`CreateAttachment::encode`.

[soundboard]: https://discord.com/developers/docs/resources/soundboard#soundboard-resource
BossFlea pushed a commit to BossFlea/serenity that referenced this pull request Sep 16, 2025
…ity-rs#3412)

Back in September 2024, Discord added [Soundboard][soundboard] APIs that allow
a bot to create a new sound by uploading raw mp3 or ogg data.

This data is specified as part of the JSON rather than a multipart upload (an
odd decision IMO); however, that means that the semantics of `ImageData` are
wrong as it makes too many assumptions about its contents. In particular, we
assume that the base64 data will always be an image, and the
`CreateAttachment::encode` method always assigns the `image/png` mimetype.

This commit removes these assumptions by renaming the struct to simply
`DataUri`, and now requiring the user to specify the mimetype when calling
`CreateAttachment::encode`.

[soundboard]: https://discord.com/developers/docs/resources/soundboard#soundboard-resource
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
…ity-rs#3412)

Back in September 2024, Discord added [Soundboard][soundboard] APIs that allow
a bot to create a new sound by uploading raw mp3 or ogg data.

This data is specified as part of the JSON rather than a multipart upload (an
odd decision IMO); however, that means that the semantics of `ImageData` are
wrong as it makes too many assumptions about its contents. In particular, we
assume that the base64 data will always be an image, and the
`CreateAttachment::encode` method always assigns the `image/png` mimetype.

This commit removes these assumptions by renaming the struct to simply
`DataUri`, and now requiring the user to specify the mimetype when calling
`CreateAttachment::encode`.

[soundboard]: https://discord.com/developers/docs/resources/soundboard#soundboard-resource
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
…ity-rs#3412)

Back in September 2024, Discord added [Soundboard][soundboard] APIs that allow
a bot to create a new sound by uploading raw mp3 or ogg data.

This data is specified as part of the JSON rather than a multipart upload (an
odd decision IMO); however, that means that the semantics of `ImageData` are
wrong as it makes too many assumptions about its contents. In particular, we
assume that the base64 data will always be an image, and the
`CreateAttachment::encode` method always assigns the `image/png` mimetype.

This commit removes these assumptions by renaming the struct to simply
`DataUri`, and now requiring the user to specify the mimetype when calling
`CreateAttachment::encode`.

[soundboard]: https://discord.com/developers/docs/resources/soundboard#soundboard-resource
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Oct 7, 2025
…ity-rs#3412)

Back in September 2024, Discord added [Soundboard][soundboard] APIs that allow
a bot to create a new sound by uploading raw mp3 or ogg data.

This data is specified as part of the JSON rather than a multipart upload (an
odd decision IMO); however, that means that the semantics of `ImageData` are
wrong as it makes too many assumptions about its contents. In particular, we
assume that the base64 data will always be an image, and the
`CreateAttachment::encode` method always assigns the `image/png` mimetype.

This commit removes these assumptions by renaming the struct to simply
`DataUri`, and now requiring the user to specify the mimetype when calling
`CreateAttachment::encode`.

[soundboard]: https://discord.com/developers/docs/resources/soundboard#soundboard-resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change The public API is changed, resulting in miscompilations or unexpected new behaviour for users builder Related to the `builder` module. enhancement An improvement to Serenity. model Related to the `model` module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants