feat: do not send notification when notify token is empty

This commit is contained in:
2020-10-15 08:37:30 +08:00
parent f2ad55691c
commit e9fdb60a80
3 changed files with 6 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -541,7 +541,7 @@ dependencies = [
[[package]] [[package]]
name = "keeprunningd" name = "keeprunningd"
version = "0.2.0" version = "0.3.0"
dependencies = [ dependencies = [
"argparse", "argparse",
"chrono", "chrono",

View File

@@ -1,7 +1,7 @@
{ {
"check_inverval_secs": 1, "check_inverval_secs": 1,
"show_debug_output": true, "show_debug_output": true,
"notify_token": "------------", "notify_token": "",
"lock_file": ".keeprunningd.lock", "lock_file": ".keeprunningd.lock",
"items": [{ "items": [{
"grep_tokens": ["java", "app"], "grep_tokens": ["java", "app"],

View File

@@ -170,6 +170,10 @@ fn keep_runningd(keep_running_config: Arc<KeepRunningConfig>) {
} }
async fn send_notify(notify_token: &str, text: &str) { async fn send_notify(notify_token: &str, text: &str) {
if notify_token.is_empty() {
info!("Notify token is empty, do not send DingTalk notification");
return;
}
match DingTalk::from_token(&notify_token) { match DingTalk::from_token(&notify_token) {
Err(err) => error!("Prepare DingTalk error: {}", err), Err(err) => error!("Prepare DingTalk error: {}", err),
Ok(dt) => if let Err(err) = dt.send_text(text).await { Ok(dt) => if let Err(err) = dt.send_text(text).await {