Redesign page + Webhook notifications #43
8 changed files with 19 additions and 15 deletions
Formatting
commit
2c7bf80a63
|
|
@ -6,7 +6,7 @@ use handlebars::Handlebars;
|
||||||
use lettre::message::header::{Header, HeaderName, HeaderValue, UserAgent};
|
use lettre::message::header::{Header, HeaderName, HeaderValue, UserAgent};
|
||||||
use lettre::message::{Mailbox, SinglePart};
|
use lettre::message::{Mailbox, SinglePart};
|
||||||
use lettre::{Address, AsyncTransport};
|
use lettre::{Address, AsyncTransport};
|
||||||
use log::{warn, debug};
|
use log::{debug, warn};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::job_offers::view::JobOfferViewData;
|
||||||
use crate::route::job_offer::error::ConfirmationResponseError;
|
use crate::route::job_offer::error::ConfirmationResponseError;
|
||||||
use crate::route::job_offer::error::ConfirmationResponseError::SuccessRenderError;
|
use crate::route::job_offer::error::ConfirmationResponseError::SuccessRenderError;
|
||||||
use crate::route::HTML_CONTENT;
|
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};
|
use crate::{get, template, JobOffers, ServerConfig};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|
@ -110,7 +110,8 @@ pub(crate) async fn confirm_joboffer_post(
|
||||||
link: job_offer.highlight_link(&req)?,
|
link: job_offer.highlight_link(&req)?,
|
||||||
};
|
};
|
||||||
send_new_offer_message(&hb, webhook_url.to_owned(), &data)
|
send_new_offer_message(&hb, webhook_url.to_owned(), &data)
|
||||||
.await.ok();
|
.await
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,7 @@ pub(crate) async fn edit_joboffer_post(
|
||||||
|
|
||||||
if let Some(tmp_file) = file {
|
if let Some(tmp_file) = file {
|
||||||
// TODO error handling
|
// TODO error handling
|
||||||
let _todo =
|
let _todo = tmp_file.persist(job_offer_folder.join(&offer.attachment_location));
|
||||||
tmp_file.persist(job_offer_folder.join(&offer.attachment_location));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(offer)
|
Some(offer)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ pub(crate) async fn review_joboffer(
|
||||||
company: entry.offering_party.to_owned(),
|
company: entry.offering_party.to_owned(),
|
||||||
link: entry.highlight_link(&req)?,
|
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
|
|||||||
|
.await
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ pub(crate) struct ProgramConfig {
|
||||||
pub(crate) login_provider: LoginProviderConfig,
|
pub(crate) login_provider: LoginProviderConfig,
|
||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub(crate) email: Option<EmailConfig>,
|
pub(crate) email: Option<EmailConfig>,
|
||||||
pub(crate) webhook_url: Option<String>
|
pub(crate) webhook_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -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> {
|
pub fn toml_date_to_chrono_date(date: &toml::value::Date) -> chrono::DateTime<FixedOffset> {
|
||||||
let local_date =
|
let local_date = NaiveDate::from_ymd_opt(date.year.into(), date.month.into(), date.day.into())
|
||||||
NaiveDate::from_ymd_opt(date.year.into(), date.month.into(), date.day.into()).expect("toml should contain valid date");
|
.expect("toml should contain valid date");
|
||||||
let offset = chrono_tz::Europe::Berlin
|
let offset = chrono_tz::Europe::Berlin
|
||||||
.offset_from_local_date(&local_date)
|
.offset_from_local_date(&local_date)
|
||||||
.map(|offset| offset.fix())
|
.map(|offset| offset.fix())
|
||||||
|
|
@ -91,13 +91,15 @@ pub fn toml_datetime_to_chrono_datetime(
|
||||||
toml_date.year.into(),
|
toml_date.year.into(),
|
||||||
toml_date.month.into(),
|
toml_date.month.into(),
|
||||||
toml_date.day.into(),
|
toml_date.day.into(),
|
||||||
).expect("toml should contain valid date")
|
)
|
||||||
|
.expect("toml should contain valid date")
|
||||||
.and_hms_nano_opt(
|
.and_hms_nano_opt(
|
||||||
toml_time.hour.into(),
|
toml_time.hour.into(),
|
||||||
toml_time.minute.into(),
|
toml_time.minute.into(),
|
||||||
toml_time.second.into(),
|
toml_time.second.into(),
|
||||||
toml_time.nanosecond,
|
toml_time.nanosecond,
|
||||||
).expect("toml should contain valid time");
|
)
|
||||||
|
.expect("toml should contain valid time");
|
||||||
|
|
||||||
let offset: FixedOffset = datetime
|
let offset: FixedOffset = datetime
|
||||||
.offset
|
.offset
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
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.