From 22820805796ee9cf01dd325b2b09359e3ac5e00a Mon Sep 17 00:00:00 2001 From: afterlifepro Date: Sun, 23 Nov 2025 00:30:57 +0000 Subject: [PATCH] actually post notifications --- src/main.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ef13a42..bf61f11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use actix_web::{App, HttpResponse, HttpServer, Responder, post, web}; +use notify_rust::Notification; use serde::Deserialize; #[derive(Deserialize)] @@ -9,10 +10,17 @@ struct NotificationData { #[post("/notify")] async fn notify(notification: web::Form) -> impl Responder { - HttpResponse::InternalServerError().body(format!( - "TODO: implement ({}: {})", - notification.name, notification.body - )) + let notification = Notification::new() + .summary(¬ification.name) + .body(¬ification.body) + .timeout(0) + .show(); + + match notification { + Ok(_) => HttpResponse::Ok().body("{\"status\": \"ok\"}"), + Err(err) => HttpResponse::InternalServerError() + .body(format!("{{\"status\": \"err\", \"err\": \"{}\"}}", err)), + } } #[actix_web::main] -- 2.51.2