♻️ refactor

This commit is contained in:
JMARyA 2022-11-12 02:31:09 +01:00
parent 553de1bcf7
commit 7351ad9c5d
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 5 additions and 10 deletions

View file

@ -1,5 +1,4 @@
use serde_json::Value; use serde_json::Value;
use std::fmt::format;
#[derive(Debug)] #[derive(Debug)]
pub struct GotifySettings { pub struct GotifySettings {

View file

@ -12,7 +12,7 @@ pub async fn notify(msg: &str, title: &str, config: Data<Config>) {
async fn gotify_notification(msg: &str, title: &str, config: config::GotifySettings) { async fn gotify_notification(msg: &str, title: &str, config: config::GotifySettings) {
info!("Sending gotify notification"); info!("Sending gotify notification");
let c = reqwest::Client::new(); let c = reqwest::Client::new();
let res = c let _ = c
.post(format!( .post(format!(
"https://{}/message?token={}", "https://{}/message?token={}",
config.host, config.token config.host, config.token

View file

@ -1,5 +1,3 @@
use reqwest::get;
pub fn is_browser(req: &actix_web::HttpRequest) -> bool { pub fn is_browser(req: &actix_web::HttpRequest) -> bool {
let ua = req let ua = req
.headers() .headers()

View file

@ -1,4 +1,3 @@
use crate::config;
use crate::config::Config; use crate::config::Config;
use actix_web::web::Data; use actix_web::web::Data;
use actix_web::*; use actix_web::*;

View file

@ -1,10 +1,8 @@
use crate::pages::html_fn::build_site;
use crate::{config, pages}; use crate::{config, pages};
use actix_web::http::header; use actix_web::http::header;
use actix_web::web::{Form, Json}; use actix_web::web::Form;
use actix_web::*; use actix_web::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::io::Read;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct MessageForm { pub struct MessageForm {
@ -21,9 +19,10 @@ pub async fn message_post(r: HttpRequest, f: Form<MessageForm>) -> impl Responde
&format!("New Message from {}", f.msg_name.to_string()), &format!("New Message from {}", f.msg_name.to_string()),
"New Message", "New Message",
config.clone(), config.clone(),
); )
.await;
return HttpResponse::Found() return HttpResponse::Found()
.header("Location", "/message") .append_header(("Location", "/message"))
.finish(); .finish();
} }