We can't mix GET and POST (in the comment form)
in_response_to was always null
This commit is contained in:
+2
-12
@@ -15,31 +15,21 @@ use plume_models::{
|
||||
};
|
||||
use inbox::Inbox;
|
||||
|
||||
#[derive(FromForm)]
|
||||
pub struct CommentQuery {
|
||||
pub responding_to: Option<i32>
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
struct NewCommentForm {
|
||||
pub responding_to: Option<i32>,
|
||||
pub content: String
|
||||
}
|
||||
|
||||
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
||||
#[post("/~/<blog_name>/<slug>/comment", data = "<data>")]
|
||||
fn create(blog_name: String, slug: String, data: LenientForm<NewCommentForm>, user: User, conn: DbConn) -> Redirect {
|
||||
create_response(blog_name, slug, None, data, user, conn)
|
||||
}
|
||||
|
||||
#[post("/~/<blog_name>/<slug>/comment?<query>", data = "<data>")]
|
||||
fn create_response(blog_name: String, slug: String, query: Option<CommentQuery>, data: LenientForm<NewCommentForm>, user: User, conn: DbConn) -> Redirect {
|
||||
let blog = Blog::find_by_fqn(&*conn, blog_name.clone()).unwrap();
|
||||
let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap();
|
||||
let form = data.get();
|
||||
|
||||
let (new_comment, id) = NewComment::build()
|
||||
.content(form.content.clone())
|
||||
.in_response_to_id(query.and_then(|q| q.responding_to))
|
||||
.in_response_to_id(form.responding_to.clone())
|
||||
.post(post)
|
||||
.author(user.clone())
|
||||
.create(&*conn);
|
||||
|
||||
+5
-1
@@ -17,7 +17,11 @@ use plume_models::{
|
||||
safe_string::SafeString,
|
||||
users::User
|
||||
};
|
||||
use routes::comments::CommentQuery;
|
||||
|
||||
#[derive(FromForm)]
|
||||
struct CommentQuery {
|
||||
responding_to: Option<i32>
|
||||
}
|
||||
|
||||
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||
|
||||
Reference in New Issue
Block a user