send-blogpost-notification #681
@ -179,6 +179,13 @@ ORDER BY read_at DESC, created_at DESC;
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn delete_by_link(db: &sqlx::Pool<Sqlite>, link: &str) {
|
||||||
|
sqlx::query!("DELETE FROM notification WHERE link=?", link)
|
||||||
|
.execute(db)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -148,6 +148,26 @@ async fn new_blogpost(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(FromForm, Debug)]
|
||||||
|
struct BlogpostUnpublishedForm<'r> {
|
||||||
|
article_url: &'r str,
|
||||||
|
pw: &'r str,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/", data = "<blogpost>")]
|
||||||
|
async fn blogpost_unpublished(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
blogpost: Form<BlogpostUnpublishedForm<'_>>,
|
||||||
|
config: &State<Config>,
|
||||||
|
) -> String {
|
||||||
|
if blogpost.pw == &config.wordpress_key {
|
||||||
|
Notification::delete_by_link(&db, blogpost.article_url).await;
|
||||||
|
"ACK".into()
|
||||||
|
} else {
|
||||||
|
"WRONG pw".into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[catch(403)] //forbidden
|
#[catch(403)] //forbidden
|
||||||
fn forbidden_error() -> Flash<Redirect> {
|
fn forbidden_error() -> Flash<Redirect> {
|
||||||
Flash::error(Redirect::to("/"), "Keine Berechtigung für diese Aktion. Wenn du der Meinung bist, dass du das machen darfst, melde dich bitte bei it@rudernlinz.at.")
|
Flash::error(Redirect::to("/"), "Keine Berechtigung für diese Aktion. Wenn du der Meinung bist, dass du das machen darfst, melde dich bitte bei it@rudernlinz.at.")
|
||||||
@ -226,6 +246,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
.mount("/auth", auth::routes())
|
.mount("/auth", auth::routes())
|
||||||
.mount("/wikiauth", routes![wikiauth])
|
.mount("/wikiauth", routes![wikiauth])
|
||||||
.mount("/new-blogpost", routes![new_blogpost])
|
.mount("/new-blogpost", routes![new_blogpost])
|
||||||
|
.mount("/blogpost-unpublished", routes![blogpost_unpublished])
|
||||||
.mount("/log", log::routes())
|
.mount("/log", log::routes())
|
||||||
.mount("/planned", planned::routes())
|
.mount("/planned", planned::routes())
|
||||||
.mount("/ergo", ergo::routes())
|
.mount("/ergo", ergo::routes())
|
||||||
|
Loading…
Reference in New Issue
Block a user