cargo fmt
This commit is contained in:
parent
05e2c31bec
commit
4c516a7d57
@ -7,7 +7,7 @@ use hyper::header::HeaderValue;
|
|||||||
use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Uri};
|
use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Uri};
|
||||||
use hyper_rustls::HttpsConnector;
|
use hyper_rustls::HttpsConnector;
|
||||||
use libflate::gzip;
|
use libflate::gzip;
|
||||||
use log::{error, debug, warn};
|
use log::{debug, error, warn};
|
||||||
use once_cell::sync::Lazy;
|
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;
|
||||||
|
@ -13,7 +13,7 @@ use log::info;
|
|||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use redsunlib::client::{canonical_path, proxy, CLIENT};
|
use redsunlib::client::{canonical_path, proxy, CLIENT};
|
||||||
use redsunlib::server::{self, RequestExt};
|
use redsunlib::server::{self, RequestExt};
|
||||||
use redsunlib::utils::{error, redirect, ThemeAssets, MascotAssets};
|
use redsunlib::utils::{error, redirect, MascotAssets, ThemeAssets};
|
||||||
use redsunlib::{config, duplicates, headers, instance_info, post, search, settings, subreddit, user};
|
use redsunlib::{config, duplicates, headers, instance_info, post, search, settings, subreddit, user};
|
||||||
|
|
||||||
use redsunlib::client::OAUTH_CLIENT;
|
use redsunlib::client::OAUTH_CLIENT;
|
||||||
@ -110,8 +110,7 @@ async fn style() -> Result<Response<Body>, String> {
|
|||||||
|
|
||||||
/// Serve mascot
|
/// Serve mascot
|
||||||
async fn mascot_image(req: Request<Body>) -> Result<Response<Body>, String> {
|
async fn mascot_image(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||||
let res = MascotAssets::get(&req.param("name").unwrap())
|
let res = MascotAssets::get(&req.param("name").unwrap()).unwrap_or(MascotAssets::get("redsunlib.png").unwrap());
|
||||||
.unwrap_or(MascotAssets::get("redsunlib.png").unwrap());
|
|
||||||
Ok(
|
Ok(
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
|
@ -6,7 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use base64::{engine::general_purpose, Engine as _};
|
use base64::{engine::general_purpose, Engine as _};
|
||||||
use hyper::{client, Body, Method, Request};
|
use hyper::{client, Body, Method, Request};
|
||||||
use log::{error, info, debug, trace};
|
use log::{debug, error, info, trace};
|
||||||
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::time::{error::Elapsed, timeout};
|
use tokio::time::{error::Elapsed, timeout};
|
||||||
|
@ -12,7 +12,7 @@ use rinja::Template;
|
|||||||
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use time::{Duration, OffsetDateTime,macros::format_description};
|
use time::{macros::format_description, Duration, OffsetDateTime};
|
||||||
|
|
||||||
use log::trace;
|
use log::trace;
|
||||||
|
|
||||||
@ -302,7 +302,6 @@ pub async fn subscriptions_filters_quicklists(req: Request<Body>) -> Result<Resp
|
|||||||
// Remove sub name from filtered list
|
// Remove sub name from filtered list
|
||||||
quicklist.retain(|s| s.to_lowercase() != part.to_lowercase());
|
quicklist.retain(|s| s.to_lowercase() != part.to_lowercase());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect back to subreddit
|
// Redirect back to subreddit
|
||||||
@ -463,7 +462,7 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
|
|||||||
// Send a request to the url
|
// Send a request to the url
|
||||||
let res = json(path, quarantined).await?;
|
let res = json(path, quarantined).await?;
|
||||||
|
|
||||||
trace!("Subreddit info from r/{} : {}",sub,res["data"]);
|
trace!("Subreddit info from r/{} : {}", sub, res["data"]);
|
||||||
|
|
||||||
// Metadata regarding the subreddit
|
// Metadata regarding the subreddit
|
||||||
let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64;
|
let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64;
|
||||||
|
@ -6,9 +6,9 @@ use crate::server::RequestExt;
|
|||||||
use crate::utils::{error, filter_posts, format_url, get_filters, nsfw_landing, param, setting, template, Post, Preferences, User};
|
use crate::utils::{error, filter_posts, format_url, get_filters, nsfw_landing, param, setting, template, Post, Preferences, User};
|
||||||
use crate::{config, utils};
|
use crate::{config, utils};
|
||||||
use hyper::{Body, Request, Response};
|
use hyper::{Body, Request, Response};
|
||||||
|
use log::trace;
|
||||||
use rinja::Template;
|
use rinja::Template;
|
||||||
use time::{macros::format_description, OffsetDateTime};
|
use time::{macros::format_description, OffsetDateTime};
|
||||||
use log::trace;
|
|
||||||
|
|
||||||
// STRUCTS
|
// STRUCTS
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
@ -112,7 +112,7 @@ async fn user(name: &str) -> Result<User, String> {
|
|||||||
|
|
||||||
// Send a request to the url
|
// Send a request to the url
|
||||||
json(path, false).await.map(|res| {
|
json(path, false).await.map(|res| {
|
||||||
trace!("User info from r/{} : {}",name,res["data"]);
|
trace!("User info from r/{} : {}", name, res["data"]);
|
||||||
// Grab creation date as unix timestamp
|
// Grab creation date as unix timestamp
|
||||||
let created_unix = res["data"]["created"].as_f64().unwrap_or(0.0).round() as i64;
|
let created_unix = res["data"]["created"].as_f64().unwrap_or(0.0).round() as i64;
|
||||||
let created = OffsetDateTime::from_unix_timestamp(created_unix).unwrap_or(OffsetDateTime::UNIX_EPOCH);
|
let created = OffsetDateTime::from_unix_timestamp(created_unix).unwrap_or(OffsetDateTime::UNIX_EPOCH);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user