~vpzom/lotide

64b62c1fe863a26374ba711d321432708e162037 — Colin Reeder 9 months ago 5038646
Require valid URLs for posts (#71)
3 files changed, 11 insertions(+), 0 deletions(-)

M res/lang/en.ftl
M res/lang/eo.ftl
M src/routes/api/mod.rs
M res/lang/en.ftl => res/lang/en.ftl +1 -0
@@ 12,6 12,7 @@ no_such_user = No such user
not_group = Not a group
password_incorrect = Incorrect password
post_content_conflict = content_markdown and content_text are mutually exclusive
post_href_invalid = Specified URL is not valid
post_needs_content = Post must contain one of href, content_text, or content_markdown
post_not_yours = That's not your post
root = lotide is running. Note that lotide itself does not include a frontend, and you'll need to install one separately.

M res/lang/eo.ftl => res/lang/eo.ftl +1 -0
@@ 12,6 12,7 @@ no_such_user = Neniu tia uzanto
not_group = Ne estas grupo
password_incorrect = Pasvorto malĝustas
post_content_conflict = content_markdown kaj content_text konfliktas
post_href_invalid = URL nevalidas.
post_needs_content = Poŝto devas enhavi unu el href, content_text, kaj content_markdown
post_not_yours = Tio ne estas via poŝto
root = lotide funkcias. Notu: lotide ne enhavas klienton, kaj vi devos instali tiun aparte.

M src/routes/api/mod.rs => src/routes/api/mod.rs +9 -0
@@ 545,6 545,15 @@ async fn route_unstable_posts_create(
        )));
    }

    if let Some(href) = &body.href {
        if let Err(_) = url::Url::parse(href) {
            return Err(crate::Error::UserError(crate::simple_response(
                hyper::StatusCode::BAD_REQUEST,
                lang.tr("post_href_invalid", None).into_owned(),
            )));
        }
    }

    // TODO validate permissions to post

    let (content_text, content_markdown, content_html) = match body.content_markdown {