We can't mix GET and POST (in the comment form)
in_response_to was always null
This commit is contained in:
parent
b26649e8c0
commit
68a041711c
|
@ -77,7 +77,9 @@ sql_function!(setval, setval_t, (seq: ::diesel::sql_types::Text, val: ::diesel::
|
|||
fn get_next_id(conn: &PgConnection, seq: &str) -> i32 {
|
||||
// We cant' use currval because it may fail if nextval have never been called before
|
||||
let next = select(nextval(seq)).get_result::<i64>(conn).expect("Next ID fail");
|
||||
select(setval(seq, next - 1)).get_result::<i64>(conn).expect("Reset ID fail");
|
||||
if next > 1 {
|
||||
select(setval(seq, next - 1)).get_result::<i64>(conn).expect("Reset ID fail");
|
||||
}
|
||||
next as i32
|
||||
}
|
||||
|
||||
|
|
10
po/en.po
10
po/en.po
|
@ -60,13 +60,15 @@ msgstr ""
|
|||
msgid "Let's go!"
|
||||
msgstr ""
|
||||
|
||||
msgid "Welcome on {{ instance_name }}"
|
||||
#, fuzzy
|
||||
msgid "Welcome on {{ instance_name | escape }}"
|
||||
msgstr "Welcome on {{ instance_name }}"
|
||||
|
||||
msgid "Notifications"
|
||||
msgstr ""
|
||||
|
||||
msgid "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
msgid ""
|
||||
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
|
||||
msgstr ""
|
||||
|
||||
msgid "This article is under the {{ license }} license."
|
||||
|
@ -184,7 +186,7 @@ msgid "Update account"
|
|||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "{{ name }}'s followers"
|
||||
msgid "{{ name | escape }}'s followers"
|
||||
msgstr "One follower"
|
||||
|
||||
#, fuzzy
|
||||
|
@ -254,7 +256,7 @@ msgstr ""
|
|||
msgid "You need to be logged in order to edit your profile"
|
||||
msgstr ""
|
||||
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
|
||||
msgstr ""
|
||||
|
||||
msgid "{{ data }} reshared your article"
|
||||
|
|
13
po/fr.po
13
po/fr.po
|
@ -62,13 +62,16 @@ msgstr "Nom"
|
|||
msgid "Let's go!"
|
||||
msgstr "C'est parti !"
|
||||
|
||||
msgid "Welcome on {{ instance_name }}"
|
||||
#, fuzzy
|
||||
msgid "Welcome on {{ instance_name | escape }}"
|
||||
msgstr "Bienvenue sur {{ instance_name }}"
|
||||
|
||||
msgid "Notifications"
|
||||
msgstr "Notifications"
|
||||
|
||||
msgid "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
|
||||
msgstr "Écrit par {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
|
||||
msgid "This article is under the {{ license }} license."
|
||||
|
@ -184,7 +187,8 @@ msgstr "Description"
|
|||
msgid "Update account"
|
||||
msgstr "Mettre à jour mes informations"
|
||||
|
||||
msgid "{{ name }}'s followers"
|
||||
#, fuzzy
|
||||
msgid "{{ name | escape }}'s followers"
|
||||
msgstr "{{ count }} abonné⋅e"
|
||||
|
||||
msgid "Followers"
|
||||
|
@ -253,7 +257,8 @@ msgstr "Vous devez vous connecter pour suivre quelqu'un"
|
|||
msgid "You need to be logged in order to edit your profile"
|
||||
msgstr "Vous devez vous connecter pour modifier votre profil"
|
||||
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
|
||||
#, fuzzy
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
|
||||
msgstr "De {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
|
||||
|
||||
msgid "{{ data }} reshared your article"
|
||||
|
|
12
po/pl.po
12
po/pl.po
|
@ -63,13 +63,16 @@ msgstr "Nazwa"
|
|||
msgid "Let's go!"
|
||||
msgstr "Przejdźmy dalej!"
|
||||
|
||||
msgid "Welcome on {{ instance_name }}"
|
||||
#, fuzzy
|
||||
msgid "Welcome on {{ instance_name | escape }}"
|
||||
msgstr "Witamy na {{ instance_name }}"
|
||||
|
||||
msgid "Notifications"
|
||||
msgstr "Powiadomienia"
|
||||
|
||||
msgid "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
"Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}"
|
||||
msgstr "Napisano przez {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
|
||||
msgid "This article is under the {{ license }} license."
|
||||
|
@ -188,7 +191,8 @@ msgstr "Opis"
|
|||
msgid "Update account"
|
||||
msgstr "Aktualizuj konto"
|
||||
|
||||
msgid "{{ name }}'s followers"
|
||||
#, fuzzy
|
||||
msgid "{{ name | escape }}'s followers"
|
||||
msgstr "Osoby śledzące {{ name }}"
|
||||
|
||||
msgid "Followers"
|
||||
|
@ -258,7 +262,7 @@ msgid "You need to be logged in order to edit your profile"
|
|||
msgstr "Musisz się zalogować , aby móc edytować swój profil"
|
||||
|
||||
#, fuzzy
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
|
||||
msgid "By {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name | escape }}{{ link_4 }}"
|
||||
msgstr "Napisano przez {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||
|
||||
msgid "{{ data }} reshared your article"
|
||||
|
|
|
@ -38,7 +38,6 @@ fn main() {
|
|||
routes::blogs::create,
|
||||
|
||||
routes::comments::create,
|
||||
routes::comments::create_response,
|
||||
|
||||
routes::instance::index,
|
||||
routes::instance::shared_inbox,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
{% if account %}
|
||||
<form method="post" action="/~/{{ blog.actor_id }}/{{ post.slug }}/comment">
|
||||
<label for="content">{{ "Your comment" | _ }}</label>
|
||||
{% if previous %}
|
||||
<input type="hidden" name="in_response_to" value="{{ previous.id }}"/>
|
||||
{% endif %}
|
||||
{# Ugly, but we don't have the choice if we don't want weird paddings #}
|
||||
<textarea id="content" name="content">{% filter trim %}{% if previous %}{% if previous.author.fqn != user_fqn %}@{{ previous.author.fqn }} {% endif %}{% for mention in previous.mentions %}{% if mention != user_fqn %}@{{ mention }} {% endif %}{% endfor %}{% endif %}{% endfilter %}</textarea>
|
||||
<input type="submit" value="{{ "Submit comment" | _ }}" />
|
||||
|
|
Loading…
Reference in New Issue