feature: post discord webhook on quote creation

This commit is contained in:
2026-04-29 00:54:44 +02:00
parent 851f73f639
commit 1578c3a708
5 changed files with 641 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ use axum::{
use axum_extra::extract::Form;
use chrono::NaiveDateTime;
use maud::{Markup, PreEscaped, html};
use reqwest::Url;
use serde::Deserialize;
use uuid::Uuid;
@@ -178,5 +179,12 @@ pub async fn form(
LogEntry::new(&mut *tx, u, LogAction::CreateQuote { id: q.id }).await?;
tx.commit().await?;
if let Ok(webhook_url) = std::env::var("DISCORD_WEBHOOK_URL") {
match Url::parse(&webhook_url) {
Ok(u) => q.post_msg_webhook(u),
Err(e) => log::error!("Tried to post webhook, failed to parse url: {e}"),
}
}
Ok(Redirect::to("/dashboard").into_response())
}