|
|
|
@ -25,11 +25,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn handle_event(event: serde_json::Value) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
if PullRequestEvent::is_a(&event)? {
|
|
|
|
|
let event = PullRequestEvent::new(&event)?;
|
|
|
|
|
fn handle_event(json_event: serde_json::Value) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
|
if PullRequestEvent::is_a(&json_event)? {
|
|
|
|
|
let event = PullRequestEvent::new(&json_event)?;
|
|
|
|
|
if event.action == "opened" {
|
|
|
|
|
println!("PullRequestEvent action {}", event.action);
|
|
|
|
|
// println!("PullRequestEvent action {}", event.action);
|
|
|
|
|
println!("{}", serde_json::to_string(&json_event)?);
|
|
|
|
|
let notification_body = format!("Pull Request opened: {}", event.title);
|
|
|
|
|
Notification::new()
|
|
|
|
|
.summary("Pull request opened.")
|
|
|
|
@ -39,7 +40,14 @@ fn handle_event(event: serde_json::Value) -> Result<(), Box<dyn std::error::Erro
|
|
|
|
|
.hint(Hint::Category("im.received".to_owned()))
|
|
|
|
|
.hint(Hint::Resident(true))
|
|
|
|
|
.timeout(0)
|
|
|
|
|
.show()?;
|
|
|
|
|
.show()?
|
|
|
|
|
.wait_for_action(|action| match action {
|
|
|
|
|
"default" => info!("you clicked \"default\""),
|
|
|
|
|
"clicked" => info!("that was correct"),
|
|
|
|
|
// here "__closed" is a hard coded keyword
|
|
|
|
|
"__closed" => info!("the notification was closed"),
|
|
|
|
|
_ => info!("Unrecognized action {}", action),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|