diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-10-23 01:50:20 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-10-23 01:50:20 +0200 |
| commit | 8e35c18e2aac958837b2c8fcb782950f86e5f214 (patch) | |
| tree | 1215c65f89961f3e6ce2e914abda73ef68ad6dd1 /mumd/src | |
| parent | cd3c1ad6c508a698314ecc59ae6de320263f740d (diff) | |
| download | mum-8e35c18e2aac958837b2c8fcb782950f86e5f214.tar.gz | |
add first notification
Diffstat (limited to 'mumd/src')
| -rw-r--r-- | mumd/src/main.rs | 1 | ||||
| -rw-r--r-- | mumd/src/state.rs | 15 | ||||
| -rw-r--r-- | mumd/src/state/user.rs | 6 |
3 files changed, 20 insertions, 2 deletions
diff --git a/mumd/src/main.rs b/mumd/src/main.rs index e88eede..79e44a2 100644 --- a/mumd/src/main.rs +++ b/mumd/src/main.rs @@ -22,6 +22,7 @@ use tokio::task::spawn_blocking; #[tokio::main] async fn main() { setup_logger(std::io::stderr(), true); + libnotify::init("mumd").unwrap(); // Oneshot channel for setting UDP CryptState from control task // For simplicity we don't deal with re-syncing, real applications would have to. diff --git a/mumd/src/state.rs b/mumd/src/state.rs index 44d8b21..6180654 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -228,6 +228,21 @@ impl State { let user = self.server_mut().unwrap().users_mut().get_mut(&sess).unwrap(); let diff = mumlib::state::UserDiff::from(msg); user.apply_user_diff(&diff); + let user = self.server().unwrap().users().get(&sess).unwrap(); + + // send notification + if let Some(channel_id) = diff.channel_id { + if let Some(channel) = self.server().unwrap().channels().get(&channel_id) { + libnotify::Notification::new("mumd", + Some(format!("{} moved to channel {}", + &user.name(), + channel.name()).as_str()), + None).show().unwrap(); + } else { + warn!("{} moved to invalid channel {}", &user.name(), channel_id); + } + } + Some(diff) } } diff --git a/mumd/src/state/user.rs b/mumd/src/state/user.rs index 679d0ff..ab867e6 100644 --- a/mumd/src/state/user.rs +++ b/mumd/src/state/user.rs @@ -1,6 +1,10 @@ +use crate::state::channel::Channel; + use log::*; use mumble_protocol::control::msgs; use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::collections::hash_map::Entry; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct User { @@ -80,7 +84,6 @@ 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); } @@ -111,7 +114,6 @@ impl User { if let Some(deaf) = diff.deaf { self.deaf = deaf; } - if let Some(channel_id) = diff.channel_id { self.channel = channel_id; } |
