aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2020-11-16 16:33:07 +0100
committerEskil Queseth <eskilq@kth.se>2020-11-16 16:33:07 +0100
commitac6b6e462f8dd7b6ab73e12b55de07b5019f232d (patch)
treef5f4e8cfbcee444c9a5027dee4fb70846de1cbe2 /mumd/src
parent3b0d0f7aee5b6d8dc4ab59c1c16315c2c80347b3 (diff)
downloadmum-ac6b6e462f8dd7b6ab73e12b55de07b5019f232d.tar.gz
clean up mute notification code
Diffstat (limited to 'mumd/src')
-rw-r--r--mumd/src/state.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/mumd/src/state.rs b/mumd/src/state.rs
index d3c793e..91cf734 100644
--- a/mumd/src/state.rs
+++ b/mumd/src/state.rs
@@ -520,27 +520,19 @@ impl State {
}
//send notification if a user muted/unmuted
- let notify_desc = match (mute, deaf) {
- (Some(true), Some(true)) => {
- Some(format!("{} muted and deafend themselves", &user.name()))
+ if mute != None || deaf != None {
+ let mut s = user.name().to_string();
+ if let Some(mute) = mute {
+ s += if mute { " muted" } else { " unmuted" };
}
- (Some(false), Some(false)) => {
- Some(format!("{} unmuted and undeafend themselves", &user.name()))
+ if mute.is_some() && deaf.is_some() {
+ s += " and";
}
- (None, Some(true)) => Some(format!("{} deafend themselves", &user.name())),
- (None, Some(false)) => Some(format!("{} undeafend themselves", &user.name())),
- (Some(true), None) => Some(format!("{} muted themselves", &user.name())),
- (Some(false), None) => Some(format!("{} unmuted themselves", &user.name())),
- (Some(true), Some(false)) => {
- Some(format!("{} muted and undeafened themselves", &user.name()))
+ if let Some(deaf) = deaf {
+ s += if deaf { " deafened" } else { " undeafened" };
}
- (Some(false), Some(true)) => {
- Some(format!("{} unmuted and deafened themselves", &user.name()))
- }
- (None, None) => None,
- };
- if let Some(notify_desc) = notify_desc {
- notify::send(notify_desc);
+ s += " themselves";
+ notify::send(s);
}
}
}