-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(model, cache): a full message object for
MessageUpdate
eve…
…nt (#2387) `MessageUpdate` event now contains a full `Message` object. Refs: - discord/discord-api-docs#7017 --------- Co-authored-by: Erk <[email protected]> Co-authored-by: ITOH <[email protected]>
- Loading branch information
1 parent
c93fb5a
commit f7a6c3e
Showing
6 changed files
with
54 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 17 additions & 58 deletions
75
twilight-model/src/gateway/payload/incoming/message_update.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,21 @@ | ||
use crate::{ | ||
channel::{ | ||
message::{Embed, Mention, MessageType}, | ||
Attachment, | ||
}, | ||
id::{ | ||
marker::{ChannelMarker, GuildMarker, MessageMarker, RoleMarker}, | ||
Id, | ||
}, | ||
user::User, | ||
util::Timestamp, | ||
}; | ||
use crate::channel::Message; | ||
use serde::{Deserialize, Serialize}; | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | ||
pub struct MessageUpdate { | ||
/// List of attachments. | ||
/// | ||
/// Refer to the documentation for [`Message::attachments`] for caveats with | ||
/// receiving the attachments of messages. | ||
/// | ||
/// [`Message::attachments`]: crate::channel::Message::attachments | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub attachments: Option<Vec<Attachment>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub author: Option<User>, | ||
pub channel_id: Id<ChannelMarker>, | ||
/// Content of the message. | ||
/// | ||
/// Refer to the documentation for [`Message::content`] for caveats with | ||
/// receiving the content of messages. | ||
/// | ||
/// [`Message::content`]: crate::channel::Message::content | ||
pub content: Option<String>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub edited_timestamp: Option<Timestamp>, | ||
/// List of embeds. | ||
/// | ||
/// Refer to the documentation for [`Message::embeds`] for caveats with | ||
/// receiving the embeds of messages. | ||
/// | ||
/// [`Message::embeds`]: crate::channel::Message::embeds | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub embeds: Option<Vec<Embed>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub guild_id: Option<Id<GuildMarker>>, | ||
pub id: Id<MessageMarker>, | ||
#[serde(rename = "type", skip_serializing_if = "Option::is_none")] | ||
pub kind: Option<MessageType>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub mention_everyone: Option<bool>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub mention_roles: Option<Vec<Id<RoleMarker>>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub mentions: Option<Vec<Mention>>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub pinned: Option<bool>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub timestamp: Option<Timestamp>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub tts: Option<bool>, | ||
#[serde(transparent)] | ||
pub struct MessageUpdate(pub Message); | ||
|
||
impl Deref for MessageUpdate { | ||
type Target = Message; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl DerefMut for MessageUpdate { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} |