mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-15 14:32:50 +00:00
Upgrade to v0.14
This commit is contained in:
parent
8bb247af3b
commit
43ed9756dc
5 changed files with 12 additions and 11 deletions
|
@ -34,11 +34,11 @@ pub async fn item(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||
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 !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);
|
||||
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 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") {
|
||||
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()));
|
||||
|
|
|
@ -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> {
|
||||
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 mut res = redirect(redir.to_owned());
|
||||
let mut res = redirect(redir);
|
||||
res.insert_cookie(
|
||||
Cookie::build(&format!("allow_quaran_{}", subreddit.to_lowercase()), "true")
|
||||
.path("/")
|
||||
|
@ -205,9 +205,10 @@ pub async fn subscriptions(req: Request<Body>) -> Result<Response<Body>, String>
|
|||
|
||||
// Redirect back to subreddit
|
||||
// check for redirect parameter if unsubscribing from outside sidebar
|
||||
let path = match param(&format!("?{}", query), "redirect") {
|
||||
Some(redirect_path) => format!("/{}/", redirect_path),
|
||||
None => format!("/r/{}", sub)
|
||||
let path = if let Some(redirect_path) = param(&format!("?{}", query), "redirect") {
|
||||
format!("/{}/", redirect_path)
|
||||
} else {
|
||||
format!("/r/{}", sub)
|
||||
};
|
||||
|
||||
let mut res = redirect(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue