Redesign page + Webhook notifications #43
2 changed files with 4 additions and 3 deletions
Keep progranm from crashing when webhook_url is not provided
- Also require webhook_url to be a valid Url
commit
995840c104
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue