Upgrade to v0.14
This commit is contained in:
parent
8bb247af3b
commit
43ed9756dc
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -609,7 +609,7 @@ checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libreddit"
|
name = "libreddit"
|
||||||
version = "0.13.1"
|
version = "0.14.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
|
@ -3,7 +3,7 @@ name = "libreddit"
|
|||||||
description = " Alternative private front-end to Reddit"
|
description = " Alternative private front-end to Reddit"
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
repository = "https://github.com/spikecodes/libreddit"
|
repository = "https://github.com/spikecodes/libreddit"
|
||||||
version = "0.13.1"
|
version = "0.14.0"
|
||||||
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ pub async fn item(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||||||
let default_sort = setting(&req, "comment_sort");
|
let default_sort = setting(&req, "comment_sort");
|
||||||
|
|
||||||
// If there's no sort query but there's a default sort, set sort to default_sort
|
// If there's no sort query but there's a default sort, set sort to default_sort
|
||||||
if !default_sort.is_empty() {
|
if default_sort.is_empty() {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
path = format!("{}.json?{}&sort={}&raw_json=1", req.uri().path(), req.uri().query().unwrap_or_default(), default_sort);
|
path = format!("{}.json?{}&sort={}&raw_json=1", req.uri().path(), req.uri().query().unwrap_or_default(), default_sort);
|
||||||
default_sort
|
default_sort
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ pub async fn find(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||||||
}
|
}
|
||||||
let query = param(&path, "q").unwrap_or_default();
|
let query = param(&path, "q").unwrap_or_default();
|
||||||
|
|
||||||
let sort = param(&path, "sort").unwrap_or("relevance".to_string());
|
let sort = param(&path, "sort").unwrap_or_else(|| "relevance".to_string());
|
||||||
|
|
||||||
let subreddits = match param(&path, "restrict_sr") {
|
let subreddits = match param(&path, "restrict_sr") {
|
||||||
None => search_subreddits(&query).await,
|
None => search_subreddits(&query).await,
|
||||||
Some(_) => Vec::new()
|
Some(_) => Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = String::from(req.uri().path_and_query().map_or("", |val| val.as_str()));
|
let url = String::from(req.uri().path_and_query().map_or("", |val| val.as_str()));
|
||||||
|
@ -133,7 +133,7 @@ pub fn quarantine(req: Request<Body>, sub: String) -> Result<Response<Body>, Str
|
|||||||
pub async fn add_quarantine_exception(req: Request<Body>) -> Result<Response<Body>, String> {
|
pub async fn add_quarantine_exception(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||||
let subreddit = req.param("sub").ok_or("Invalid URL")?;
|
let subreddit = req.param("sub").ok_or("Invalid URL")?;
|
||||||
let redir = param(&format!("?{}", req.uri().query().unwrap_or_default()), "redir").ok_or("Invalid URL")?;
|
let redir = param(&format!("?{}", req.uri().query().unwrap_or_default()), "redir").ok_or("Invalid URL")?;
|
||||||
let mut res = redirect(redir.to_owned());
|
let mut res = redirect(redir);
|
||||||
res.insert_cookie(
|
res.insert_cookie(
|
||||||
Cookie::build(&format!("allow_quaran_{}", subreddit.to_lowercase()), "true")
|
Cookie::build(&format!("allow_quaran_{}", subreddit.to_lowercase()), "true")
|
||||||
.path("/")
|
.path("/")
|
||||||
@ -205,9 +205,10 @@ pub async fn subscriptions(req: Request<Body>) -> Result<Response<Body>, String>
|
|||||||
|
|
||||||
// Redirect back to subreddit
|
// Redirect back to subreddit
|
||||||
// check for redirect parameter if unsubscribing from outside sidebar
|
// check for redirect parameter if unsubscribing from outside sidebar
|
||||||
let path = match param(&format!("?{}", query), "redirect") {
|
let path = if let Some(redirect_path) = param(&format!("?{}", query), "redirect") {
|
||||||
Some(redirect_path) => format!("/{}/", redirect_path),
|
format!("/{}/", redirect_path)
|
||||||
None => format!("/r/{}", sub)
|
} else {
|
||||||
|
format!("/r/{}", sub)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut res = redirect(path);
|
let mut res = redirect(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user