mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-07 02:31:32 +00:00
Don't send out new user email verifies to admins, if already verified. (#5288)
- Fixes #5272
This commit is contained in:
parent
ba779b978f
commit
e9d27f2840
1 changed files with 9 additions and 6 deletions
|
@ -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(),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue