Add call to create notification.

This commit is contained in:
Tom Alexander
2022-05-12 09:32:26 -04:00
parent 11ddea7f53
commit c8b9e73c75
3 changed files with 704 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ mod githubctl;
mod json_util;
use githubctl::PullRequestEvent;
use notify_rust::{Hint, Notification};
use serde_json;
const USERNAME: &'static str = include_str!("../.username");
@@ -29,6 +30,16 @@ fn handle_event(event: serde_json::Value) -> Result<(), Box<dyn std::error::Erro
let event = PullRequestEvent::new(&event)?;
if event.action == "opened" {
println!("PullRequestEvent action {}", event.action);
let notification_body = format!("Pull Request opened: {}", event.title);
Notification::new()
.summary("Pull request opened.")
.body(notification_body.as_str())
// .icon("can be a full path to an image file")
.appname("github_watcher")
.hint(Hint::Category("im.received".to_owned()))
.hint(Hint::Resident(true))
.timeout(0)
.show()?;
}
}
Ok(())