add a link to reviewer notice mail and update dependencies #34
7 changed files with 39 additions and 8 deletions
add highlight link to reviewer notice email
commit
fe6bf4621d
|
|
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Change
|
||||
- reviewer notice now includes a link to the added job offer
|
||||
|
||||
### Fix
|
||||
- confirmation dialog for when logged-in as a reviewer
|
||||
|
||||
|
|
|
|||
23
src/email.rs
23
src/email.rs
|
|
@ -6,6 +6,7 @@ use lettre::message::header::{Header, HeaderName, HeaderValue, UserAgent};
|
|||
use lettre::message::{Mailbox, SinglePart};
|
||||
use lettre::{Address, AsyncTransport};
|
||||
use log::warn;
|
||||
use serde_json::json;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -64,19 +65,31 @@ pub(crate) async fn send_confirmation_email(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn send_reviewer_notice(email_config: &EmailConfig) {
|
||||
pub(crate) async fn send_reviewer_notice(
|
||||
hb: &Handlebars<'_>,
|
||||
email_config: &EmailConfig,
|
||||
url: Url,
|
||||
) {
|
||||
// successfully send a confirmation e-mail now send a notice to our-self
|
||||
|
||||
let body = match hb.render(
|
||||
template::EMAIL_REVIEWER_NOTICE,
|
||||
&json!({ "highlight_link": url }),
|
||||
) {
|
||||
Ok(body) => body,
|
||||
Err(err) => {
|
||||
warn!("Failed to render reviewer notice email: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let message = lettre::Message::builder()
|
||||
.from(email_config.from.to_owned())
|
||||
.to(email_config.from.to_owned())
|
||||
.subject(&email_config.subject)
|
||||
.header(user_agent())
|
||||
.header(AutoGeneratedHeader::default())
|
||||
.singlepart(SinglePart::plain(
|
||||
"Automatischer Hinweis: Eine neue Stellenausschreibung wurde zur Jobbörse eingereicht!"
|
||||
.to_owned(),
|
||||
));
|
||||
.singlepart(SinglePart::plain(body));
|
||||
|
||||
match message {
|
||||
Ok(msg) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::borrow::Cow;
|
||||
use std::borrow::{Borrow, Cow};
|
||||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::collections::BTreeMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
|
@ -744,6 +744,10 @@ impl<'id> MutBorrowedJobOffer<'_, 'id, '_> {
|
|||
self.data.deref_mut()
|
||||
}
|
||||
|
||||
pub(crate) fn highlight_link(&self, req: &HttpRequest) -> Result<Url, UrlGenerationError> {
|
||||
self.data.highlight_link(self.id.borrow(), req)
|
||||
}
|
||||
|
||||
pub(crate) async fn try_clean(&mut self) -> Result<(), SaveError> {
|
||||
if !self.is_clean() {
|
||||
// we have not saved our changes yet, try once to do so
|
||||
|
|
|
|||
|
|
@ -250,7 +250,14 @@ pub(crate) async fn create_job_offer<'data, 'config>(
|
|||
|
||||
if let Some(email_config) = &config.config.email {
|
||||
if !is_pre_approved {
|
||||
email::send_reviewer_notice(&email_config).await;
|
||||
match created_offer.highlight_link(req) {
|
||||
Ok(highlight_url) => {
|
||||
email::send_reviewer_notice(hb, &email_config, highlight_url).await;
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failed to generate highlight link: {}", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !skip_confirmation {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub(crate) async fn review_joboffer(
|
|||
if requires_review && entry.is_published() {
|
||||
if let Some(email_config) = &config.config.email {
|
||||
let data = PublishNoticeEmailData {
|
||||
highlight_link: entry.highlight_link(entry.id(), &req)?,
|
||||
highlight_link: entry.highlight_link(&req)?,
|
||||
};
|
||||
crate::email::send_publish_notice(
|
||||
&hb,
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@ pub(crate) const LICENCES: &str = "licenses";
|
|||
|
||||
pub const EMAIL_CONFIRMATION_PLAIN: &str = "email/confirmation_plaintext";
|
||||
pub const EMAIL_PUBLISH_NOTICE_PLAIN: &str = "email/publish_notice_plaintext";
|
||||
pub const EMAIL_REVIEWER_NOTICE: &str = "email/reviewer_notice_plaintext";
|
||||
|
|
|
|||
3
templates/email/reviewer_notice.hb
Normal file
3
templates/email/reviewer_notice.hb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Automatischer Hinweis: Eine neue Stellenausschreibung wurde zur Jobbörse eingereicht!
|
||||
|
||||
{{highlight_link}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue