aboutsummaryrefslogtreecommitdiff
path: root/src/notify.rs
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2023-11-28 16:14:34 +0100
committerGitHub <noreply@github.com>2023-11-28 16:14:34 +0100
commitd32c836554772c3fca738a3629bcb244e60d67ae (patch)
tree8ae17fa304c23bdcab7827122366547aef61d3f0 /src/notify.rs
parent09ce40640757c764ce9be124a689ae244d0a2112 (diff)
parent342064df385632d50854f1d52147505297f19a04 (diff)
downloadRSS-watcher-d32c836554772c3fca738a3629bcb244e60d67ae.tar.gz
RSS-watcher-d32c836554772c3fca738a3629bcb244e60d67ae.zip
Merge pull request #4 from micwoj92/master
format code
Diffstat (limited to 'src/notify.rs')
-rw-r--r--src/notify.rs26
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 {