me-site/src/notification.rs
2022-11-12 02:31:09 +01:00

25 lines
691 B
Rust

use crate::config;
use crate::config::Config;
use actix_web::web::Data;
use log::*;
pub async fn notify(msg: &str, title: &str, config: Data<Config>) {
if let Some(gotify) = config.gotify_config() {
gotify_notification(msg, title, gotify).await;
}
}
async fn gotify_notification(msg: &str, title: &str, config: config::GotifySettings) {
info!("Sending gotify notification");
let c = reqwest::Client::new();
let _ = c
.post(format!(
"https://{}/message?token={}",
config.host, config.token
))
.header("title", title)
.header("message", msg)
.header("priority", 5)
.send()
.await;
}