send-blogpost-notification #680

Merged
philipp merged 7 commits from send-blogpost-notification into main 2024-08-18 22:24:16 +02:00
4 changed files with 7 additions and 2 deletions
Showing only changes of commit 83aa9bc84c - Show all commits

1
Cargo.lock generated
View File

@ -2271,6 +2271,7 @@ dependencies = [
"sqlx",
"tera",
"ureq",
"urlencoding",
]
[[package]]

View File

@ -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" ] }

View File

@ -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,

View File

@ -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