Don't send out new user email verifies to admins, if already verified. (#5288)

- Fixes #5272
This commit is contained in:
Dessalines 2025-01-03 05:16:25 -05:00 committed by GitHub
parent ba779b978f
commit e9d27f2840
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,11 @@ pub async fn verify_email(
let site_view = SiteView::read_local(&mut context.pool()).await?;
let token = data.token.clone();
let verification = EmailVerification::read_for_token(&mut context.pool(), &token).await?;
let local_user_id = verification.local_user_id;
let local_user_view = LocalUserView::read(&mut context.pool(), local_user_id).await?;
// Check if their email has already been verified once, before this
let email_already_verified = local_user_view.local_user.email_verified;
let form = LocalUserUpdateForm {
// necessary in case this is a new signup
@ -27,18 +32,16 @@ pub async fn verify_email(
email: Some(Some(verification.email)),
..Default::default()
};
let local_user_id = verification.local_user_id;
LocalUser::update(&mut context.pool(), local_user_id, &form).await?;
EmailVerification::delete_old_tokens_for_local_user(&mut context.pool(), local_user_id).await?;
// send out notification about registration application to admins if enabled
if site_view.local_site.application_email_admins {
let local_user = LocalUserView::read(&mut context.pool(), local_user_id).await?;
// Send out notification about registration application to admins if enabled, and the user hasn't
// already been verified.
if site_view.local_site.application_email_admins && !email_already_verified {
send_new_applicant_email_to_admins(
&local_user.person.name,
&local_user_view.person.name,
&mut context.pool(),
context.settings(),
)