Address fmt + clippy

This commit is contained in:
Matthew Esposito 2023-03-25 16:32:42 -04:00
parent cef9266648
commit f465394f93
No known key found for this signature in database
4 changed files with 31 additions and 24 deletions

View File

@ -1,13 +1,13 @@
use cached::proc_macro::cached; use cached::proc_macro::cached;
use futures_lite::{future::Boxed, FutureExt}; use futures_lite::{future::Boxed, FutureExt};
use hyper::{body, body::Buf, client, header, Body, Method, Request, Response, Uri, Client}; use hyper::client::HttpConnector;
use hyper::{body, body::Buf, client, header, Body, Client, Method, Request, Response, Uri};
use hyper_rustls::HttpsConnector;
use libflate::gzip; use libflate::gzip;
use once_cell::sync::Lazy;
use percent_encoding::{percent_encode, CONTROLS}; use percent_encoding::{percent_encode, CONTROLS};
use serde_json::Value; use serde_json::Value;
use std::{io, result::Result}; use std::{io, result::Result};
use hyper::client::HttpConnector;
use hyper_rustls::HttpsConnector;
use once_cell::sync::Lazy;
use crate::dbg_msg; use crate::dbg_msg;
use crate::server::RequestExt; use crate::server::RequestExt;
@ -142,7 +142,14 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
.header("Accept-Encoding", if method == Method::GET { "gzip" } else { "identity" }) .header("Accept-Encoding", if method == Method::GET { "gzip" } else { "identity" })
.header("Accept-Language", "en-US,en;q=0.5") .header("Accept-Language", "en-US,en;q=0.5")
.header("Connection", "keep-alive") .header("Connection", "keep-alive")
.header("Cookie", if quarantine { "_options=%7B%22pref_quarantine_optin%22%3A%20true%2C%20%22pref_gated_sr_optin%22%3A%20true%7D" } else { "" }) .header(
"Cookie",
if quarantine {
"_options=%7B%22pref_quarantine_optin%22%3A%20true%2C%20%22pref_gated_sr_optin%22%3A%20true%7D"
} else {
""
},
)
.body(Body::empty()); .body(Body::empty());
async move { async move {

View File

@ -253,7 +253,7 @@ impl Server {
.boxed() .boxed()
} }
// If there was a routing error // If there was a routing error
Err(e) => async move { new_boilerplate(def_headers, req_headers, 404, e.into()).await }.boxed(), Err(e) => new_boilerplate(def_headers, req_headers, 404, e.into()).boxed(),
} }
})) }))
} }
@ -379,7 +379,7 @@ fn determine_compressor(accept_encoding: String) -> Option<CompressionType> {
// This loop reads the requested compressors and keeps track of whichever // This loop reads the requested compressors and keeps track of whichever
// one has the highest priority per our heuristic. // one has the highest priority per our heuristic.
for val in accept_encoding.to_string().split(',') { for val in accept_encoding.split(',') {
let mut q: f64 = 1.0; let mut q: f64 = 1.0;
// The compressor and q-value (if the latter is defined) // The compressor and q-value (if the latter is defined)

View File

@ -530,21 +530,21 @@ impl Preferences {
} }
Self { Self {
available_themes: themes, available_themes: themes,
theme: setting(&req, "theme"), theme: setting(req, "theme"),
front_page: setting(&req, "front_page"), front_page: setting(req, "front_page"),
layout: setting(&req, "layout"), layout: setting(req, "layout"),
wide: setting(&req, "wide"), wide: setting(req, "wide"),
show_nsfw: setting(&req, "show_nsfw"), show_nsfw: setting(req, "show_nsfw"),
blur_nsfw: setting(&req, "blur_nsfw"), blur_nsfw: setting(req, "blur_nsfw"),
use_hls: setting(&req, "use_hls"), use_hls: setting(req, "use_hls"),
hide_hls_notification: setting(&req, "hide_hls_notification"), hide_hls_notification: setting(req, "hide_hls_notification"),
autoplay_videos: setting(&req, "autoplay_videos"), autoplay_videos: setting(req, "autoplay_videos"),
disable_visit_reddit_confirmation: setting(&req, "disable_visit_reddit_confirmation"), disable_visit_reddit_confirmation: setting(req, "disable_visit_reddit_confirmation"),
comment_sort: setting(&req, "comment_sort"), comment_sort: setting(req, "comment_sort"),
post_sort: setting(&req, "post_sort"), post_sort: setting(req, "post_sort"),
subscriptions: setting(&req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), subscriptions: setting(req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
filters: setting(&req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(), filters: setting(req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
hide_awards: setting(&req, "hide_awards"), hide_awards: setting(req, "hide_awards"),
} }
} }
} }