Skip to content

Commit

Permalink
Register the 'status' setting for users
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Hellyer committed Jan 27, 2017
1 parent e891ebe commit 0b9bf91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build.rs
Expand Up @@ -411,6 +411,12 @@ impl {0} {{
format!(r#"try!(opt(&mut map, "{}", |v| decode_array(v, into_string)))"#,
field_name)
},
(_struct_name, false, false, Some(def), Some(custom), None, None) => {
format!(r#"try!(remove(&mut map, "{}").and_then({})).unwrap_or({})"#,
field_name,
custom,
def)
},
(struct_name, false, false, Some(def), None, Some(from), None) => {
format!(r#"try!(opt(&mut map, "{}", {}::decode)).unwrap_or({})"#,
from,
Expand Down
4 changes: 4 additions & 0 deletions definitions/structs/user_settings.yml
Expand Up @@ -23,6 +23,10 @@ fields:
type: GuildId
- name: show_current_game
type: bool
- name: status
custom: OnlineStatus::decode_str
default: OnlineStatus::Online
type: OnlineStatus
- name: theme
type: string
decode: false
2 changes: 2 additions & 0 deletions src/model/event.rs
Expand Up @@ -817,6 +817,7 @@ pub struct UserSettingsUpdateEvent {
pub theme: Option<String>,
pub convert_emoticons: Option<bool>,
pub friend_source_flags: Option<FriendSourceFlags>,
pub status: Option<OnlineStatus>,
}

impl UserSettingsUpdateEvent {
Expand All @@ -834,6 +835,7 @@ impl UserSettingsUpdateEvent {
theme: opt(&mut map, "theme", into_string)?,
convert_emoticons: remove(&mut map, "convert_emoticons").ok().and_then(|v| v.as_bool()),
friend_source_flags: opt(&mut map, "friend_source_flags", FriendSourceFlags::decode)?,
status: opt(&mut map, "status", OnlineStatus::decode_str)?,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/model/user.rs
Expand Up @@ -9,6 +9,7 @@ use super::{
GuildInfo,
Member,
Message,
OnlineStatus,
PrivateChannel,
RoleId,
UserSettings,
Expand Down Expand Up @@ -453,6 +454,7 @@ impl UserSettings {
restricted_guilds: remove(&mut map, "restricted_guilds").and_then(|v| decode_array(v, GuildId::decode))?,
show_current_game: req!(remove(&mut map, "show_current_game")?.as_bool()),
theme: remove(&mut map, "theme").and_then(into_string)?,
status: remove(&mut map, "status").and_then(OnlineStatus::decode_str)?,
}).map(Some)
}
}

0 comments on commit 0b9bf91

Please sign in to comment.