Redesign page + Webhook notifications #43

Merged
ldr merged 16 commits from facelift into main 2023-12-25 21:23:53 +01:00
2 changed files with 4 additions and 3 deletions
Showing only changes of commit 995840c104 - Show all commits

Keep progranm from crashing when webhook_url is not provided

- Also require webhook_url to be a valid Url
Lukas Drescher 2023-12-25 18:58:00 +01:00

View file

@ -37,7 +37,8 @@ pub(crate) struct ProgramConfig {
pub(crate) login_provider: LoginProviderConfig,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub(crate) email: Option<EmailConfig>,
pub(crate) webhook_url: Option<String>,
#[serde(default)]
pub(crate) webhook_url: Option<Url>,
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -18,7 +18,7 @@ pub(crate) struct NewOfferWebhookData {
pub(crate) async fn send_new_offer_message(
hb: &Handlebars<'_>,
webhook_url: String,
webhook_url: Url,
data: &NewOfferWebhookData,
) -> Result<bool, RenderError> {
let message_text = hb.render(template::WEBHOOK_NEW_OFFER_MESSAGE, data)?;
@ -39,7 +39,7 @@ pub(crate) async fn send_new_offer_message(
let arc = Arc::new(tls_config);
let connector = Connector::new().rustls(arc);
let client = Client::builder().connector(connector).finish();
let request_result = client.post(webhook_url).send_json(&msg).await;
let request_result = client.post(webhook_url.as_str()).send_json(&msg).await;
let success = match request_result {
Ok(response) => {
debug!(