Redesign page + Webhook notifications #43

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

Formatting

Lukas Drescher 2023-12-25 01:55:37 +01:00

View file

@ -6,7 +6,7 @@ use handlebars::Handlebars;
use lettre::message::header::{Header, HeaderName, HeaderValue, UserAgent};
use lettre::message::{Mailbox, SinglePart};
use lettre::{Address, AsyncTransport};
use log::{warn, debug};
use log::{debug, warn};
use serde_json::json;
use url::Url;

View file

@ -9,7 +9,7 @@ use crate::job_offers::view::JobOfferViewData;
use crate::route::job_offer::error::ConfirmationResponseError;
use crate::route::job_offer::error::ConfirmationResponseError::SuccessRenderError;
use crate::route::HTML_CONTENT;
use crate::webhook::{NewOfferWebhookData, send_new_offer_message};
use crate::webhook::{send_new_offer_message, NewOfferWebhookData};
use crate::{get, template, JobOffers, ServerConfig};
#[derive(Serialize)]
@ -110,7 +110,8 @@ pub(crate) async fn confirm_joboffer_post(
link: job_offer.highlight_link(&req)?,
};
send_new_offer_message(&hb, webhook_url.to_owned(), &data)
.await.ok();
.await
.ok();
}
_ => {}
};

View file

@ -153,8 +153,7 @@ pub(crate) async fn edit_joboffer_post(
if let Some(tmp_file) = file {
// TODO error handling
let _todo =
tmp_file.persist(job_offer_folder.join(&offer.attachment_location));
let _todo = tmp_file.persist(job_offer_folder.join(&offer.attachment_location));
}
Some(offer)

View file

@ -48,7 +48,9 @@ pub(crate) async fn review_joboffer(
company: entry.offering_party.to_owned(),
link: entry.highlight_link(&req)?,
};
crate::webhook::send_new_offer_message(&hb, webhook_url.to_owned(), &data).await.ok();
crate::webhook::send_new_offer_message(&hb, webhook_url.to_owned(), &data)
ldr marked this conversation as resolved

Not aborting because the webhook failed is what I would expect, but it might be good to log the error instead of just ignoring it.

Not aborting because the webhook failed is what I would expect, but it might be good to log the error instead of just ignoring it.

This is now being logged directly inside the function.

This is now being logged directly inside the function.
.await
.ok();
}
}
}

View file

@ -37,7 +37,7 @@ 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>
pub(crate) webhook_url: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -59,8 +59,8 @@ pub fn chrono_datetime_to_toml_datetime<Tz: chrono::TimeZone>(
}
pub fn toml_date_to_chrono_date(date: &toml::value::Date) -> chrono::DateTime<FixedOffset> {
let local_date =
NaiveDate::from_ymd_opt(date.year.into(), date.month.into(), date.day.into()).expect("toml should contain valid date");
let local_date = NaiveDate::from_ymd_opt(date.year.into(), date.month.into(), date.day.into())
.expect("toml should contain valid date");
let offset = chrono_tz::Europe::Berlin
.offset_from_local_date(&local_date)
.map(|offset| offset.fix())
@ -91,13 +91,15 @@ pub fn toml_datetime_to_chrono_datetime(
toml_date.year.into(),
toml_date.month.into(),
toml_date.day.into(),
).expect("toml should contain valid date")
)
.expect("toml should contain valid date")
.and_hms_nano_opt(
toml_time.hour.into(),
toml_time.minute.into(),
toml_time.second.into(),
toml_time.nanosecond,
).expect("toml should contain valid time");
)
.expect("toml should contain valid time");
let offset: FixedOffset = datetime
.offset