diff options
| author | Zeyla Hellyer <[email protected]> | 2017-05-27 09:13:06 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-27 09:13:06 -0700 |
| commit | 0102706321a00cfb39b356bdf2cf8d523b93a8ec (patch) | |
| tree | 6d2ba524b5ddeabf590b1c10d03900dbd1d8ef21 /src/model | |
| parent | Fix GuildChannel::create_permission anchor link (diff) | |
| download | serenity-0102706321a00cfb39b356bdf2cf8d523b93a8ec.tar.xz serenity-0102706321a00cfb39b356bdf2cf8d523b93a8ec.zip | |
Fix incorrect attempted send_file deserialization
If http::send_file received a non-success status code due to reasons
such as sending to an invalid channel Id, not having permissions, or
sending too large of a file, then it would still try to deserialize
a response as if it were valid.
To fix this, ensure that the response is successful. Document that if
the file sent is too large, then
`HttpError::InvalidRequest(PayloadTooLarge)` is returned.
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel/channel_id.rs | 6 | ||||
| -rw-r--r-- | src/model/channel/group.rs | 5 | ||||
| -rw-r--r-- | src/model/channel/guild_channel.rs | 5 | ||||
| -rw-r--r-- | src/model/channel/mod.rs | 5 | ||||
| -rw-r--r-- | src/model/channel/private_channel.rs | 5 |
5 files changed, 26 insertions, 0 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index b360bd1..121399a 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -382,6 +382,12 @@ impl ChannelId { /// [`ModelError::MessageTooLong`] will be returned, containing the number /// of unicode code points over the limit. /// + /// Returns an + /// [`HttpError::InvalidRequest(PayloadTooLarge)`][`HttpError::InvalidRequest`] + /// if the file is too large to send. + /// + /// + /// [`HttpError::InvalidRequest`]: ../http/enum.HttpError.html#variant.InvalidRequest /// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong /// [`CreateMessage::content`]: ../builder/struct.CreateMessage.html#method.content /// [`GuildChannel`]: struct.GuildChannel.html diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs index adafdc8..aab3e3a 100644 --- a/src/model/channel/group.rs +++ b/src/model/channel/group.rs @@ -285,11 +285,16 @@ impl Group { /// /// # Errors /// + /// Returns an + /// [`HttpError::InvalidRequest(PayloadTooLarge)`][`HttpError::InvalidRequest`] + /// if the file is too large to send. + /// /// If the content of the message is over the above limit, then a /// [`ModelError::MessageTooLong`] will be returned, containing the number /// of unicode code points over the limit. /// /// [`ChannelId::send_file`]: struct.ChannelId.html#method.send_file + /// [`HttpError::InvalidRequest`]: ../http/enum.HttpError.html#variant.InvalidRequest /// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong /// [Attach Files]: permissions/constant.ATTACH_FILES.html /// [Send Messages]: permissions/constant.SEND_MESSAGES.html diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index 93584b6..25dcc36 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -544,11 +544,16 @@ impl GuildChannel { /// /// # Errors /// + /// Returns an + /// [`HttpError::InvalidRequest(PayloadTooLarge)`][`HttpError::InvalidRequest`] + /// if the file is too large to send. + /// /// If the content of the message is over the above limit, then a /// [`ModelError::MessageTooLong`] will be returned, containing the number /// of unicode code points over the limit. /// /// [`ChannelId::send_file`]: struct.ChannelId.html#method.send_file + /// [`HttpError::InvalidRequest`]: ../http/enum.HttpError.html#variant.InvalidRequest /// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong /// [Attach Files]: permissions/constant.ATTACH_FILES.html /// [Send Messages]: permissions/constant.SEND_MESSAGES.html diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index b82b22c..300f402 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -280,11 +280,16 @@ impl Channel { /// /// # Errors /// + /// Returns an + /// [`HttpError::InvalidRequest(PayloadTooLarge)`][`HttpError::InvalidRequest`] + /// if the file is too large to send. + /// /// If the content of the message is over the above limit, then a /// [`ModelError::MessageTooLong`] will be returned, containing the number /// of unicode code points over the limit. /// /// [`ChannelId::send_file`]: struct.ChannelId.html#method.send_file + /// [`HttpError::InvalidRequest`]: ../http/enum.HttpError.html#variant.InvalidRequest /// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong /// [Attach Files]: permissions/constant.ATTACH_FILES.html /// [Send Messages]: permissions/constant.SEND_MESSAGES.html diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs index 9e2aec1..d63efff 100644 --- a/src/model/channel/private_channel.rs +++ b/src/model/channel/private_channel.rs @@ -231,11 +231,16 @@ impl PrivateChannel { /// /// # Errors /// + /// Returns an + /// [`HttpError::InvalidRequest(PayloadTooLarge)`][`HttpError::InvalidRequest`] + /// if the file is too large to send. + /// /// If the content of the message is over the above limit, then a /// [`ModelError::MessageTooLong`] will be returned, containing the number /// of unicode code points over the limit. /// /// [`ChannelId::send_file`]: struct.ChannelId.html#method.send_file + /// [`HttpError::InvalidRequest`]: ../http/enum.HttpError.html#variant.InvalidRequest /// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong /// [Attach Files]: permissions/constant.ATTACH_FILES.html /// [Send Messages]: permissions/constant.SEND_MESSAGES.html |