diff options
author | micwoj92 <45581170+micwoj92@users.noreply.github.com> | 2023-11-21 20:16:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-21 20:16:20 +0100 |
commit | 342064df385632d50854f1d52147505297f19a04 (patch) | |
tree | 8ae17fa304c23bdcab7827122366547aef61d3f0 /src/notify.rs | |
parent | 09ce40640757c764ce9be124a689ae244d0a2112 (diff) | |
download | RSS-watcher-342064df385632d50854f1d52147505297f19a04.tar.gz RSS-watcher-342064df385632d50854f1d52147505297f19a04.zip |
format code
Diffstat (limited to 'src/notify.rs')
-rw-r--r-- | src/notify.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/notify.rs b/src/notify.rs index 19915db..9d7e81b 100644 --- a/src/notify.rs +++ b/src/notify.rs @@ -1,14 +1,19 @@ use crate::database::FeedConf; use crate::rss_utils; -use log::{info, error}; +use chrono::prelude::{DateTime, Utc}; use feed_rs::model::Feed; -use chrono::prelude::{Utc,DateTime}; +use log::{error, info}; /** * Push feed entry to gotify */ -async fn gotify(title: String, message: String, link: Option<String>, feed_conf: &FeedConf) -> Result<(), reqwest::Error> { +async fn gotify( + title: String, + message: String, + link: Option<String>, + feed_conf: &FeedConf, +) -> Result<(), reqwest::Error> { let uri = format!("{}/message", &feed_conf.push_url); // Build json string that will be sent as payload to gotify @@ -17,7 +22,7 @@ async fn gotify(title: String, message: String, link: Option<String>, feed_conf: req.push_str(format!("\"title\":\"{}\"", title).as_str()); req.push_str(format!(",\"message\":\"{}\"", message).as_str()); req.push_str(",\"priority\":1"); - + req.push_str(",\"extras\": {"); req.push_str("\"client::display\": { \"contentType\": \"text/markdown\" }"); if link.is_some() { @@ -29,12 +34,13 @@ async fn gotify(title: String, message: String, link: Option<String>, feed_conf: // Send request to gotify let client = reqwest::Client::new(); - let res = client.post(uri) - .query(&[("token",&feed_conf.push_token)]) - .body(req.to_owned()) - .header("Content-Type", "application/json") - .send() - .await?; + let res = client + .post(uri) + .query(&[("token", &feed_conf.push_token)]) + .body(req.to_owned()) + .header("Content-Type", "application/json") + .send() + .await?; if res.status().is_success() { info!("Sent notification with title \"{}\"", title); } else { |