| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
| |
Adds the `Message::member` structfield, which contains a partial amount
of member data (deaf and mute status, role IDs, and joined_at).
|
| |
|
|
|
|
|
|
|
|
| |
Adds an animated structfield to `Emoji` and `ReactionType`'s `Custom`
variant, which defaults to false if not present.
A test has been added for deserializing it, taken from a REST API GET
Emojis response.
(cherry picked from commit 5286949f424e824784344ebb7b7af4e52fb819c3)
|
| |
|
|
|
|
|
| |
Fix the deserialization of `model::guild::Guild` when
`Guild::system_channel_id` is not present.
Additionally, add a test case for this.
|
| |
|
|
|
| |
The tests for guild deserialization were failing due to new support for
more fields, but old JSON test cases didn't have those fields.
|
| |
|
|
|
|
|
| |
Fix the deserialization of the `Guild::application_id` structfield.
Additionally, create a new ID type for it.
A test has been added for this.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When Discord adds new features, the Feature enum will not be able to
serialize the new values until updated, causing the entire Guild
deserialization to fail.
Due to the fact that these features can be added at any time, the
`features` vector on Guild and PartialGuild have been changed to be a
`Vec<String>`.
Upgrade path:
Instead of matching on variants of Feature like so:
```rust
use serenity::model::Feature;
for feature in guild.features {
if feature == Feature::VipRegions {
// do work with this info
}
}
```
Instead opt to check the string name of the feature:
```rust
for feature in guild.features {
if feature == "VIP_REGIONS" {
// do work with this info
}
}
```
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
Negative message nonces caused deserialization errors, as serde would
not deserialize integers into strings.
To fix this, change `Message::nonce` into an `Option<Snowflake>` from an
`Option<String>`. This new `Snowflake` is a wrapper around an `i64`. Use
a new `I64Visitor` to deserialize i64s, u64s, and strs into the wanted
i64.
|
| |
|
|
|
|
|
|
|
|
| |
When message type 7 is received from the gateway, transform the content
if the type is 7 to a proper greeting.
Additionally, when the type is 6, provide a proper content notifying that a
user has pinned a message to the channel.
These transformations are not done at REST-level when retrieving messages, and
are instead done in `ChannelId::message` and `ChannelId::messages`.
|
| |
|
|
|
|
|
|
|
| |
Deserializing a non-custom emoji would fail, as an Id would always be
expected.
To fix this, special-case that if a name and id are both present, to
deserialize it as a Custom emoji reaction. Otherwise, use only the name
and deserialize as a basic reaction.
|
| |
|
|
|
|
| |
Due to the serde 1.0 upgrade, integers are no longer automatically
deserialized from Strings. To resolve this, create a visitor that
performs the operation based on the input.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Add a test suite for most of the events that can be easily procuced,
and store them in static JSON files so the tests are ran on every build.
The recent update to using serde{,_derive} for deserialization was a
rough patch, as it was a large change which couldn't be fully tested at
the time. By adding JSON files which are deserialized, this will produce
a test suite that can be easily run on every new set of commits to
prevent any backwards incompatible changes with regards to
deserialization.
|
|
|
The current build system is rudimentary, incomplete, and rigid, offering
little in the way of customizing decoding options.
To solve this, switch to using serde-derive with custom Deserialization
implementations. This allows very simple deserialization when special
logic does not need to be applied, yet allows us to implement our own
deserialization logic when required.
The problem with the build system was that it built enums and structs
from YAML files. This is not so good, because it requires creating a
custom build system (which was rudimentary), creating "special struct
configs" when logic needed to be ever so slightly extended (rigid), and
if special logic needed to be applied, a custom deserialization method
would have been needed to be made anyway (incomplete).
To solve this, switch to serde-derive and implementing Deserialize
ourselves where required. This reduces YAML definitions that might
look like:
```yaml
---
name: Group
description: >
A group channel, potentially including other users, separate from a [`Guild`].
[`Guild`]: struct.Guild.html
fields:
- name: channel_id
description: The Id of the group channel.
from: id
type: ChannelId
- name: icon
description: The optional icon of the group channel.
optional: true
type: string
- name: last_message_id
description: The Id of the last message sent.
optional: true
type: MessageId
- name: last_pin_timestamp
description: Timestamp of the latest pinned message.
optional: true
type: string
- name: name
description: The name of the group channel.
optional: true
type: string
- name: owner_id
description: The Id of the group channel creator.
type: UserId
- name: recipients
description: Group channel's members.
custom: decode_users
t: UserId, Arc<RwLock<User>>
type: hashmap
```
to:
```rs
/// A group channel - potentially including other [`User`]s - separate from a
/// [`Guild`].
///
/// [`Guild`]: struct.Guild.html
/// [`User`]: struct.User.html
pub struct Group {
/// The Id of the group channel.
#[serde(rename="id")]
pub channel_id: ChannelId,
/// The optional icon of the group channel.
pub icon: Option<String>,
/// The Id of the last message sent.
pub last_message_id: Option<MessageId>,
/// Timestamp of the latest pinned message.
pub last_pin_timestamp: Option<String>,
/// The name of the group channel.
pub name: Option<String>,
/// The Id of the group owner.
pub owner_id: UserId,
/// A map of the group's recipients.
#[serde(deserialize_with="deserialize_users")]
pub recipients: HashMap<UserId, Arc<RwLock<User>>>,
}
```
This is much simpler and does not have as much boilerplate.
There should not be any backwards incompatible changes other than the
old, public - yet undocumented (and hidden from documentation) - decode
methods being removed. Due to the nature of this commit, field names may
be incorrect, and will need to be corrected as deserialization errors
are found.
|