send-blogpost-notification #680
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2271,6 +2271,7 @@ dependencies = [
|
||||
"sqlx",
|
||||
"tera",
|
||||
"ureq",
|
||||
"urlencoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -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" ] }
|
||||
|
@ -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,
|
||||
|
@ -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,6 +91,7 @@ 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),
|
||||
'article_title' => urlencode($article_title),
|
||||
'pw' => "pw-as-specified-in-rockettoml"
|
||||
), $api_url);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user