aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/state
diff options
context:
space:
mode:
Diffstat (limited to 'mumd/src/state')
-rw-r--r--mumd/src/state/server.rs4
-rw-r--r--mumd/src/state/user.rs40
2 files changed, 44 insertions, 0 deletions
diff --git a/mumd/src/state/server.rs b/mumd/src/state/server.rs
index b7cabb7..b99c7e6 100644
--- a/mumd/src/state/server.rs
+++ b/mumd/src/state/server.rs
@@ -98,6 +98,10 @@ impl Server {
&self.users
}
+ pub fn users_mut(&mut self) -> &mut HashMap<u32, User> {
+ &mut self.users
+ }
+
pub fn username(&self) -> Option<&str> {
self.username.as_ref().map(|e| e.as_str())
}
diff --git a/mumd/src/state/user.rs b/mumd/src/state/user.rs
index bb4e101..679d0ff 100644
--- a/mumd/src/state/user.rs
+++ b/mumd/src/state/user.rs
@@ -1,3 +1,4 @@
+use log::*;
use mumble_protocol::control::msgs;
use serde::{Deserialize, Serialize};
@@ -78,6 +79,45 @@ impl User {
}
}
+ pub fn apply_user_diff(&mut self, diff: &mumlib::state::UserDiff) {
+ debug!("applying user diff\n{:#?}", diff);
+ if let Some(comment) = diff.comment.clone() {
+ self.comment = Some(comment);
+ }
+ if let Some(hash) = diff.hash.clone() {
+ self.hash = Some(hash);
+ }
+ if let Some(name) = diff.name.clone() {
+ self.name = name;
+ }
+ if let Some(priority_speaker) = diff.priority_speaker {
+ self.priority_speaker = priority_speaker;
+ }
+ if let Some(recording) = diff.recording {
+ self.recording = recording;
+ }
+ if let Some(suppress) = diff.suppress {
+ self.suppress = suppress;
+ }
+ if let Some(self_mute) = diff.self_mute {
+ self.self_mute = self_mute;
+ }
+ if let Some(self_deaf) = diff.self_deaf {
+ self.self_deaf = self_deaf;
+ }
+ if let Some(mute) = diff.mute {
+ self.mute = mute;
+ }
+ if let Some(deaf) = diff.deaf {
+ self.deaf = deaf;
+ }
+
+ if let Some(channel_id) = diff.channel_id {
+ self.channel = channel_id;
+ }
+ }
+
+
pub fn name(&self) -> &str {
&self.name
}