mirror of
https://github.com/redlib-org/redlib.git
synced 2025-05-15 22:42:52 +00:00
Change subscription to get. Add subs to settings.
This commit is contained in:
parent
dc2030e6f3
commit
449899962a
5 changed files with 62 additions and 21 deletions
|
@ -100,7 +100,7 @@ async fn main() -> std::io::Result<()> {
|
|||
.route("/", web::get().to(subreddit::page))
|
||||
.route("/{sort:hot|new|top|rising|controversial}/", web::get().to(subreddit::page))
|
||||
// Handle subscribe/unsubscribe
|
||||
.route("/{action:subscribe|unsubscribe}/", web::post().to(subreddit::subscriptions))
|
||||
.route("/{action:subscribe|unsubscribe}/", web::get().to(subreddit::subscriptions))
|
||||
// View post on subreddit
|
||||
.service(
|
||||
web::scope("/comments/{id}/{title}")
|
||||
|
|
|
@ -103,7 +103,16 @@ pub async fn subscriptions(req: HttpRequest) -> HttpResponse {
|
|||
}
|
||||
|
||||
// Redirect back to subreddit
|
||||
let path = format!("/r/{}", sub);
|
||||
// check for redirect parameter if unsubscribing from outside sidebar
|
||||
let redirect_path = param(&format!("{}?{}", req.path(), req.query_string()), "redirect");
|
||||
let path;
|
||||
|
||||
if redirect_path.len() > 1 && redirect_path.chars().nth(0).unwrap() == '/' {
|
||||
path = redirect_path;
|
||||
} else {
|
||||
path = format!("/r/{}", sub);
|
||||
}
|
||||
|
||||
res
|
||||
.content_type("text/html")
|
||||
.set_header("Location", path.to_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue