2022-11-12 00:41:51 +01:00
|
|
|
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();
|
2022-11-12 02:31:09 +01:00
|
|
|
let _ = c
|
2022-11-12 00:41:51 +01:00
|
|
|
.post(format!(
|
|
|
|
"https://{}/message?token={}",
|
|
|
|
config.host, config.token
|
|
|
|
))
|
|
|
|
.header("title", title)
|
|
|
|
.header("message", msg)
|
|
|
|
.header("priority", 5)
|
|
|
|
.send()
|
|
|
|
.await;
|
|
|
|
}
|