Compare commits
1 Commits
navbar-qui
...
main
Author | SHA1 | Date | |
---|---|---|---|
4c516a7d57 |
@ -7,7 +7,7 @@ use hyper::header::HeaderValue;
|
||||
use hyper::{body, body::Buf, header, Body, Client, Method, Request, Response, Uri};
|
||||
use hyper_rustls::HttpsConnector;
|
||||
use libflate::gzip;
|
||||
use log::{error, debug, warn};
|
||||
use log::{debug, error, warn};
|
||||
use once_cell::sync::Lazy;
|
||||
use percent_encoding::{percent_encode, CONTROLS};
|
||||
use serde_json::Value;
|
||||
|
@ -148,7 +148,7 @@ impl InstanceInfo {
|
||||
["Show NSFW", &convert(&self.config.default_show_nsfw)],
|
||||
["Blur NSFW", &convert(&self.config.default_blur_nsfw)],
|
||||
["Use HLS", &convert(&self.config.default_use_hls)],
|
||||
["Use FFmpeg", &convert(&self.config.default_ffmpeg_video_downloads)],
|
||||
["Use FFmpeg", &convert(&self.config.default_ffmpeg_video_downloads)],
|
||||
["Hide HLS notification", &convert(&self.config.default_hide_hls_notification)],
|
||||
["Subscriptions", &convert(&self.config.default_subscriptions)],
|
||||
["Filters", &convert(&self.config.default_filters)],
|
||||
|
@ -13,7 +13,7 @@ use log::info;
|
||||
use once_cell::sync::Lazy;
|
||||
use redsunlib::client::{canonical_path, proxy, CLIENT};
|
||||
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::client::OAUTH_CLIENT;
|
||||
@ -110,8 +110,7 @@ async fn style() -> Result<Response<Body>, String> {
|
||||
|
||||
/// Serve mascot
|
||||
async fn mascot_image(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||
let res = MascotAssets::get(&req.param("name").unwrap())
|
||||
.unwrap_or(MascotAssets::get("redsunlib.png").unwrap());
|
||||
let res = MascotAssets::get(&req.param("name").unwrap()).unwrap_or(MascotAssets::get("redsunlib.png").unwrap());
|
||||
Ok(
|
||||
Response::builder()
|
||||
.status(200)
|
||||
@ -249,7 +248,7 @@ async fn main() {
|
||||
|
||||
app.at("/commits.json").get(|_| async move { proxy_commit_info().await }.boxed());
|
||||
app.at("/instances.json").get(|_| async move { proxy_instances().await }.boxed());
|
||||
|
||||
|
||||
// FFmpeg
|
||||
app
|
||||
.at("/ffmpeg/814.ffmpeg.js")
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
};
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use hyper::{client, Body, Method, Request};
|
||||
use log::{error, info, debug, trace};
|
||||
use log::{debug, error, info, trace};
|
||||
|
||||
use serde_json::json;
|
||||
use tokio::time::{error::Elapsed, timeout};
|
||||
|
@ -12,7 +12,7 @@ use rinja::Template;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use time::{Duration, OffsetDateTime,macros::format_description};
|
||||
use time::{macros::format_description, Duration, OffsetDateTime};
|
||||
|
||||
use log::trace;
|
||||
|
||||
@ -301,8 +301,7 @@ pub async fn subscriptions_filters_quicklists(req: Request<Body>) -> Result<Resp
|
||||
} else if action.contains(&"unquicklist".to_string()) {
|
||||
// Remove sub name from filtered list
|
||||
quicklist.retain(|s| s.to_lowercase() != part.to_lowercase());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect back to subreddit
|
||||
@ -463,12 +462,12 @@ async fn subreddit(sub: &str, quarantined: bool) -> Result<Subreddit, String> {
|
||||
// Send a request to the url
|
||||
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
|
||||
let members: i64 = res["data"]["subscribers"].as_u64().unwrap_or_default() as i64;
|
||||
let active: i64 = res["data"]["accounts_active"].as_u64().unwrap_or_default() as i64;
|
||||
|
||||
|
||||
// Grab creation date as unix timestamp
|
||||
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);
|
||||
|
@ -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::{config, utils};
|
||||
use hyper::{Body, Request, Response};
|
||||
use log::trace;
|
||||
use rinja::Template;
|
||||
use time::{macros::format_description, OffsetDateTime};
|
||||
use log::trace;
|
||||
|
||||
// STRUCTS
|
||||
#[derive(Template)]
|
||||
@ -112,7 +112,7 @@ async fn user(name: &str) -> Result<User, String> {
|
||||
|
||||
// Send a request to the url
|
||||
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
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user