extract to twba-common

This commit is contained in:
OMGeeky
2024-05-02 23:27:53 +02:00
parent 696a7ca3b6
commit edde4b1299
2 changed files with 4 additions and 8 deletions

5
Cargo.lock generated
View File

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

View File

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