Skip to content

Commit

Permalink
Send emails to removed visitors
Browse files Browse the repository at this point in the history
  • Loading branch information
Celeo committed Jan 4, 2025
1 parent 718b909 commit b378ee5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vzdv-site/src/endpoints/controller.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! HTTP endpoints for controller pages.
use crate::{
email::{self, send_mail},
flashed_messages::{self, MessageLevel},
shared::{
js_timestamp_to_utc, post_audit, record_log, reject_if_not_in, strip_some_tags, AppError,
Expand Down Expand Up @@ -897,6 +898,7 @@ async fn post_remove_controller(
)
.await
.map_err(|e| AppError::GenericFallback("removing home controller", e))?;
// VATUSA handles emailing the user for home facility removals
record_log(
format!(
"{} removed home controller {cid}, reason: {}",
Expand All @@ -915,6 +917,23 @@ async fn post_remove_controller(
)
.await
.map_err(|e| AppError::GenericFallback("removing visiting controller", e))?;
// we're responsible for informing visitors of their removal
let controller_info =
vatusa::get_controller_info(cid, Some(&state.config.vatsim.vatusa_api_key))
.await
.map_err(|err| AppError::GenericFallback("getting controller info", err))?;
if let Some(ref email) = controller_info.email {
send_mail(
&state.config,
&state.db,
&format!("{} {}", controller.first_name, controller.last_name),
email,
email::templates::VISITOR_REMOVED,
)
.await?;
} else {
warn!("Could not get email for {cid} to inform of removal from the visitor roster");
}
record_log(
format!(
"{} removed visiting controller {cid}, reason: {}",
Expand Down
1 change: 1 addition & 0 deletions vzdv-site/templates/changelog.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ul>
<li>Controller feedback form default controller fixed</li>
<li>Controller feedback form position made into a simplified dropdown, and some other textual changes</li>
<li>Visitors removed from the roster now receive emails direct from ZDV</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit b378ee5

Please sign in to comment.