diff --git a/Cargo.lock b/Cargo.lock index 4aed81e..a459ecd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2271,6 +2271,7 @@ dependencies = [ "sqlx", "tera", "ureq", + "urlencoding", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 39208c5..d75e236 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ itertools = "0.13" job_scheduler_ng = "2.0" ureq = { version = "2.9", features = ["json"] } regex = "1.10" +urlencoding = "2.1" [target.'cfg(not(windows))'.dependencies] openssl = { version = "0.10", features = [ "vendored" ] } diff --git a/src/tera/mod.rs b/src/tera/mod.rs index 982a1b7..8ef6830 100644 --- a/src/tera/mod.rs +++ b/src/tera/mod.rs @@ -121,6 +121,7 @@ fn unauthorized_error(req: &Request) -> Redirect { #[derive(FromForm, Debug)] struct NewBlogpostForm<'r> { article_url: &'r str, + article_title: &'r str, pw: &'r str, } @@ -135,7 +136,7 @@ async fn new_blogpost( Notification::create_for_role( db, &member, - &format!("auf unserer Website!"), + &urlencoding::decode(blogpost.article_title).expect("UTF-8"), &format!("Neuer Blogpost"), Some(blogpost.article_url), None, diff --git a/wordpress-notes.md b/wordpress-notes.md index 8170489..3eee2b1 100644 --- a/wordpress-notes.md +++ b/wordpress-notes.md @@ -83,6 +83,7 @@ function send_article_url_on_publish($new_status, $old_status, $post) { if ($new_status == 'publish' && $old_status != 'publish' && $post->post_type == 'post') { // Get the URL of the newly published article $article_url = get_permalink($post->ID); + $article_title = get_the_title($post->ID); // URL to send the GET request to $api_url = 'https://staging.rudernlinz.at/new-blogpost'; @@ -90,7 +91,8 @@ function send_article_url_on_publish($new_status, $old_status, $post) { // Add the article URL as a query parameter $request_url = add_query_arg(array( 'article_url' => urlencode($article_url), - 'pw' => "pw-as-specified-in-rockettoml" + 'article_title' => urlencode($article_title), + 'pw' => "pw-as-specified-in-rockettoml" ), $api_url); // Send the GET request