Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model): guild member update includes deaf, mute #774

Merged
merged 3 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cache/in-memory/src/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ impl UpdateCache for MemberUpdate {
};
let mut member = Arc::make_mut(&mut member);

member.deaf = self.deaf.unwrap_or(member.deaf);
member.mute = self.mute.unwrap_or(member.mute);
member.nick = self.nick.clone();
member.roles = self.roles.clone();
member.joined_at.replace(self.joined_at.clone());
Expand Down
12 changes: 11 additions & 1 deletion model/src/gateway/payload/member_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct MemberUpdate {
pub guild_id: GuildId,
pub deaf: Option<bool>,
pub joined_at: String,
pub mute: Option<bool>,
pub nick: Option<String>,
/// Whether the user has yet to pass the guild's [Membership Screening]
/// requirements.
Expand Down Expand Up @@ -55,20 +57,28 @@ mod tests {
nick: Some("Twilight".to_string()),
joined_at: "2017-02-27T22:21:50.121000+00:00".to_string(),
guild_id: 1_234.into(),
deaf: Some(false),
mute: Some(false),
};

serde_test::assert_tokens(
&value,
&[
Token::Struct {
name: "MemberUpdate",
len: 7,
len: 9,
},
Token::Str("guild_id"),
Token::NewtypeStruct { name: "GuildId" },
Token::Str("1234"),
Token::Str("deaf"),
Token::Some,
Token::Bool(false),
Token::Str("joined_at"),
Token::Str("2017-02-27T22:21:50.121000+00:00"),
Token::Str("mute"),
Token::Some,
Token::Bool(false),
Token::Str("nick"),
Token::Some,
Token::Str("Twilight"),
Expand Down