mirror of
https://github.com/OMGeeky/twba.notifier.git
synced 2026-01-03 09:58:25 +01:00
extract to twba-common
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -3387,9 +3387,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "twba-common"
|
||||
version = "0.2.2"
|
||||
source = "git+https://github.com/OMGeeky/twba.common.git#f5e537c3a3d70a6f21ac1b354ae390ecba7bb057"
|
||||
version = "0.2.3"
|
||||
source = "git+https://github.com/OMGeeky/twba.common.git#3e502063cc36b06c0d2aa41bddd89f999f35d6e8"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
|
||||
@@ -11,11 +11,6 @@ struct NotificationWebhookMessage {
|
||||
content: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
struct NotificationRequest {
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
#[instrument]
|
||||
async fn index() -> impl Responder {
|
||||
@@ -32,7 +27,7 @@ async fn post_notify(req_body: String, data: web::Data<AppState>) -> impl Respon
|
||||
}
|
||||
|
||||
async fn post_notify_inner(req_body: String, data: web::Data<AppState>) -> Result<String, String> {
|
||||
let req_body = serde_json::from_str::<NotificationRequest>(&req_body)
|
||||
let req_body = serde_json::from_str::<twba_common::notify::NotificationRequest>(&req_body)
|
||||
.map_err(|e| format!("Could not parse request body: {e}"))
|
||||
.map(|req| NotificationWebhookMessage {
|
||||
content: req.message,
|
||||
|
||||
Reference in New Issue
Block a user