Compare commits

..

No commits in common. "8efb3aea2ceb9e73b2d81d7616b4e9f759a5410a" and "25161fc8e953c842549c7401ff1784408d9765f7" have entirely different histories.

5 changed files with 2 additions and 56 deletions

1
Cargo.lock generated
View File

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

View File

@ -28,7 +28,6 @@ itertools = "0.13"
job_scheduler_ng = "2.0" job_scheduler_ng = "2.0"
ureq = { version = "2.9", features = ["json"] } ureq = { version = "2.9", features = ["json"] }
regex = "1.10" regex = "1.10"
urlencoding = "2.1"
[target.'cfg(not(windows))'.dependencies] [target.'cfg(not(windows))'.dependencies]
openssl = { version = "0.10", features = [ "vendored" ] } openssl = { version = "0.10", features = [ "vendored" ] }

View File

@ -5,4 +5,4 @@ limits = { file = "10 MiB", data-form = "10 MiB"}
smtp_pw = "8kIjlLH79Ky6D3jQ" smtp_pw = "8kIjlLH79Ky6D3jQ"
usage_log_path = "./usage.txt" usage_log_path = "./usage.txt"
openweathermap_key = "c8dab8f91b5b815d76e9879cbaecd8d5" openweathermap_key = "c8dab8f91b5b815d76e9879cbaecd8d5"
wordpress_key = "pw-to-allow-sending-notifications" wordpress_key = "KYplHPxd6Gtqjdx4Ruik"

View File

@ -71,54 +71,3 @@ remove_action('authenticate', 'wp_authenticate_username_password', 20);
add_filter( 'authenticate', 'rot_auth', 10, 3 ); add_filter( 'authenticate', 'rot_auth', 10, 3 );
``` ```
# Wordpress notify rowt on newly published article
Add the following code to `wp-content/themes/bravada/functions.php`:
```
function send_article_url_on_publish($new_status, $old_status, $post) {
// Check if the post is transitioning to 'publish' status
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 POST request to
$api_url = 'https://app.rudernlinz.at/new-blogpost';
// Prepare the data for the POST request
$body = array(
'article_url' => $article_url,
'article_title' => $article_title,
'pw' => "pw-as-specified-in-rockettoml"
);
// Prepare the arguments for wp_remote_post
$args = array(
'body' => $body,
'timeout' => '5',
'redirection' => '5',
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'cookies' => array()
);
// Send the POST request
$response = wp_remote_post($api_url, $args);
// Optional: Check if the request was successful
if (is_wp_error($response)) {
error_log('Failed to send POST request: ' . $response->get_error_message());
} else {
error_log('POST request sent successfully with article URL: ' . $article_url);
}
}
}
// Hook the function to the 'transition_post_status' action
add_action('transition_post_status', 'send_article_url_on_publish', 10, 3);
```

View File

@ -121,7 +121,6 @@ fn unauthorized_error(req: &Request) -> Redirect {
#[derive(FromForm, Debug)] #[derive(FromForm, Debug)]
struct NewBlogpostForm<'r> { struct NewBlogpostForm<'r> {
article_url: &'r str, article_url: &'r str,
article_title: &'r str,
pw: &'r str, pw: &'r str,
} }
@ -136,7 +135,7 @@ async fn new_blogpost(
Notification::create_for_role( Notification::create_for_role(
db, db,
&member, &member,
&urlencoding::decode(blogpost.article_title).expect("UTF-8"), &format!("auf unserer Website!"),
&format!("Neuer Blogpost"), &format!("Neuer Blogpost"),
Some(blogpost.article_url), Some(blogpost.article_url),
None, None,