mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 19:41:03 +00:00
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
8 changed files with 36 additions and 27 deletions
|
@ -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 {
|
fn get_next_id(conn: &PgConnection, seq: &str) -> i32 {
|
||||||
// We cant' use currval because it may fail if nextval have never been called before
|
// 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");
|
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
|
next as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
po/en.po
10
po/en.po
|
@ -60,13 +60,15 @@ msgstr ""
|
||||||
msgid "Let's go!"
|
msgid "Let's go!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Welcome on {{ instance_name }}"
|
#, fuzzy
|
||||||
|
msgid "Welcome on {{ instance_name | escape }}"
|
||||||
msgstr "Welcome on {{ instance_name }}"
|
msgstr "Welcome on {{ instance_name }}"
|
||||||
|
|
||||||
msgid "Notifications"
|
msgid "Notifications"
|
||||||
msgstr ""
|
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 ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "This article is under the {{ license }} license."
|
msgid "This article is under the {{ license }} license."
|
||||||
|
@ -184,7 +186,7 @@ msgid "Update account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "{{ name }}'s followers"
|
msgid "{{ name | escape }}'s followers"
|
||||||
msgstr "One follower"
|
msgstr "One follower"
|
||||||
|
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
|
@ -254,7 +256,7 @@ msgstr ""
|
||||||
msgid "You need to be logged in order to edit your profile"
|
msgid "You need to be logged in order to edit your profile"
|
||||||
msgstr ""
|
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 ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "{{ data }} reshared your article"
|
msgid "{{ data }} reshared your article"
|
||||||
|
|
13
po/fr.po
13
po/fr.po
|
@ -62,13 +62,16 @@ msgstr "Nom"
|
||||||
msgid "Let's go!"
|
msgid "Let's go!"
|
||||||
msgstr "C'est parti !"
|
msgstr "C'est parti !"
|
||||||
|
|
||||||
msgid "Welcome on {{ instance_name }}"
|
#, fuzzy
|
||||||
|
msgid "Welcome on {{ instance_name | escape }}"
|
||||||
msgstr "Bienvenue sur {{ instance_name }}"
|
msgstr "Bienvenue sur {{ instance_name }}"
|
||||||
|
|
||||||
msgid "Notifications"
|
msgid "Notifications"
|
||||||
msgstr "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 }}"
|
msgstr "Écrit par {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||||
|
|
||||||
msgid "This article is under the {{ license }} license."
|
msgid "This article is under the {{ license }} license."
|
||||||
|
@ -184,7 +187,8 @@ msgstr "Description"
|
||||||
msgid "Update account"
|
msgid "Update account"
|
||||||
msgstr "Mettre à jour mes informations"
|
msgstr "Mettre à jour mes informations"
|
||||||
|
|
||||||
msgid "{{ name }}'s followers"
|
#, fuzzy
|
||||||
|
msgid "{{ name | escape }}'s followers"
|
||||||
msgstr "{{ count }} abonné⋅e"
|
msgstr "{{ count }} abonné⋅e"
|
||||||
|
|
||||||
msgid "Followers"
|
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"
|
msgid "You need to be logged in order to edit your profile"
|
||||||
msgstr "Vous devez vous connecter pour modifier votre profil"
|
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 }}"
|
msgstr "De {{ link_1 }}{{ link_2 }}{{ link_3 }}{{ name }}{{ link_4 }}"
|
||||||
|
|
||||||
msgid "{{ data }} reshared your article"
|
msgid "{{ data }} reshared your article"
|
||||||
|
|
12
po/pl.po
12
po/pl.po
|
@ -63,13 +63,16 @@ msgstr "Nazwa"
|
||||||
msgid "Let's go!"
|
msgid "Let's go!"
|
||||||
msgstr "Przejdźmy dalej!"
|
msgstr "Przejdźmy dalej!"
|
||||||
|
|
||||||
msgid "Welcome on {{ instance_name }}"
|
#, fuzzy
|
||||||
|
msgid "Welcome on {{ instance_name | escape }}"
|
||||||
msgstr "Witamy na {{ instance_name }}"
|
msgstr "Witamy na {{ instance_name }}"
|
||||||
|
|
||||||
msgid "Notifications"
|
msgid "Notifications"
|
||||||
msgstr "Powiadomienia"
|
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 }}"
|
msgstr "Napisano przez {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||||
|
|
||||||
msgid "This article is under the {{ license }} license."
|
msgid "This article is under the {{ license }} license."
|
||||||
|
@ -188,7 +191,8 @@ msgstr "Opis"
|
||||||
msgid "Update account"
|
msgid "Update account"
|
||||||
msgstr "Aktualizuj konto"
|
msgstr "Aktualizuj konto"
|
||||||
|
|
||||||
msgid "{{ name }}'s followers"
|
#, fuzzy
|
||||||
|
msgid "{{ name | escape }}'s followers"
|
||||||
msgstr "Osoby śledzące {{ name }}"
|
msgstr "Osoby śledzące {{ name }}"
|
||||||
|
|
||||||
msgid "Followers"
|
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"
|
msgstr "Musisz się zalogować , aby móc edytować swój profil"
|
||||||
|
|
||||||
#, fuzzy
|
#, 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 }}"
|
msgstr "Napisano przez {{ link_1 }}{{ url }}{{ link_2 }}{{ name }}{{ link_3 }}"
|
||||||
|
|
||||||
msgid "{{ data }} reshared your article"
|
msgid "{{ data }} reshared your article"
|
||||||
|
|
|
@ -38,7 +38,6 @@ fn main() {
|
||||||
routes::blogs::create,
|
routes::blogs::create,
|
||||||
|
|
||||||
routes::comments::create,
|
routes::comments::create,
|
||||||
routes::comments::create_response,
|
|
||||||
|
|
||||||
routes::instance::index,
|
routes::instance::index,
|
||||||
routes::instance::shared_inbox,
|
routes::instance::shared_inbox,
|
||||||
|
|
|
@ -15,31 +15,21 @@ use plume_models::{
|
||||||
};
|
};
|
||||||
use inbox::Inbox;
|
use inbox::Inbox;
|
||||||
|
|
||||||
#[derive(FromForm)]
|
|
||||||
pub struct CommentQuery {
|
|
||||||
pub responding_to: Option<i32>
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(FromForm)]
|
#[derive(FromForm)]
|
||||||
struct NewCommentForm {
|
struct NewCommentForm {
|
||||||
|
pub responding_to: Option<i32>,
|
||||||
pub content: String
|
pub content: String
|
||||||
}
|
}
|
||||||
|
|
||||||
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
|
||||||
#[post("/~/<blog_name>/<slug>/comment", data = "<data>")]
|
#[post("/~/<blog_name>/<slug>/comment", data = "<data>")]
|
||||||
fn create(blog_name: String, slug: String, data: LenientForm<NewCommentForm>, user: User, conn: DbConn) -> Redirect {
|
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 blog = Blog::find_by_fqn(&*conn, blog_name.clone()).unwrap();
|
||||||
let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap();
|
let post = Post::find_by_slug(&*conn, slug.clone(), blog.id).unwrap();
|
||||||
let form = data.get();
|
let form = data.get();
|
||||||
|
|
||||||
let (new_comment, id) = NewComment::build()
|
let (new_comment, id) = NewComment::build()
|
||||||
.content(form.content.clone())
|
.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)
|
.post(post)
|
||||||
.author(user.clone())
|
.author(user.clone())
|
||||||
.create(&*conn);
|
.create(&*conn);
|
||||||
|
|
|
@ -17,7 +17,11 @@ use plume_models::{
|
||||||
safe_string::SafeString,
|
safe_string::SafeString,
|
||||||
users::User
|
users::User
|
||||||
};
|
};
|
||||||
use routes::comments::CommentQuery;
|
|
||||||
|
#[derive(FromForm)]
|
||||||
|
struct CommentQuery {
|
||||||
|
responding_to: Option<i32>
|
||||||
|
}
|
||||||
|
|
||||||
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
// See: https://github.com/SergioBenitez/Rocket/pull/454
|
||||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||||
|
|
|
@ -63,6 +63,9 @@
|
||||||
{% if account %}
|
{% if account %}
|
||||||
<form method="post" action="/~/{{ blog.actor_id }}/{{ post.slug }}/comment">
|
<form method="post" action="/~/{{ blog.actor_id }}/{{ post.slug }}/comment">
|
||||||
<label for="content">{{ "Your comment" | _ }}</label>
|
<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 #}
|
{# 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>
|
<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" | _ }}" />
|
<input type="submit" value="{{ "Submit comment" | _ }}" />
|
||||||
|
|
Loading…
Reference in a new issue