feature: post discord webhook on quote creation
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user