@ -14,6 +14,7 @@ use lemmy_db_schema::{
password_reset_request ::PasswordResetRequest ,
password_reset_request ::PasswordResetRequest ,
person_block ::PersonBlock ,
person_block ::PersonBlock ,
post ::{ Post , PostRead , PostReadForm } ,
post ::{ Post , PostRead , PostReadForm } ,
registration_application ::RegistrationApplication ,
secret ::Secret ,
secret ::Secret ,
site ::Site ,
site ::Site ,
} ,
} ,
@ -426,8 +427,8 @@ pub async fn send_verification_email(
let body = format! (
let body = format! (
concat! (
concat! (
"Please click the link below to verify your email address " ,
"Please click the link below to verify your email address " ,
"for the account @{}@{}. Ignore this email if the account isn't yours. \n\n ",
"for the account @{}@{}. Ignore this email if the account isn't yours. <br><br> ",
"<a href=\"{}\"> </a>"
"<a href=\"{}\"> Verify your email </a>"
) ,
) ,
username , settings . hostname , verify_link
username , settings . hostname , verify_link
) ;
) ;
@ -441,7 +442,7 @@ pub fn send_email_verification_success(
settings : & Settings ,
settings : & Settings ,
) -> Result < ( ) , LemmyError > {
) -> Result < ( ) , LemmyError > {
let email = & local_user_view . local_user . email . to_owned ( ) . expect ( "email" ) ;
let email = & local_user_view . local_user . email . to_owned ( ) . expect ( "email" ) ;
let subject = & format! ( "Email verified for {}" , local_user_view . person . name ) ;
let subject = & format! ( "Email verified for {}" , local_user_view . person . actor_id ) ;
let html = "Your email has been verified." ;
let html = "Your email has been verified." ;
send_email ( subject , email , & local_user_view . person . name , html , settings )
send_email ( subject , email , & local_user_view . person . name , html , settings )
}
}
@ -452,8 +453,8 @@ pub fn send_application_approved_email(
) -> Result < ( ) , LemmyError > {
) -> Result < ( ) , LemmyError > {
let email = & local_user_view . local_user . email . to_owned ( ) . expect ( "email" ) ;
let email = & local_user_view . local_user . email . to_owned ( ) . expect ( "email" ) ;
let subject = & format! (
let subject = & format! (
"Registration to {} approved for {}",
"Registration approved for {}",
settings. hostname , local_user_view. person . name
local_user_view. person . actor_id
) ;
) ;
let html = & format! (
let html = & format! (
"Your registration application has been approved. Welcome to {}!" ,
"Your registration application has been approved. Welcome to {}!" ,
@ -461,3 +462,24 @@ pub fn send_application_approved_email(
) ;
) ;
send_email ( subject , email , & local_user_view . person . name , html , settings )
send_email ( subject , email , & local_user_view . person . name , html , settings )
}
}
pub async fn check_registration_application (
site : & Site ,
local_user_view : & LocalUserView ,
pool : & DbPool ,
) -> Result < ( ) , LemmyError > {
if site . require_application & & ! local_user_view . local_user . accepted_application {
// Fetch the registration, see if its denied
let local_user_id = local_user_view . local_user . id ;
let registration = blocking ( pool , move | conn | {
RegistrationApplication ::find_by_local_user_id ( conn , local_user_id )
} )
. await ? ? ;
if registration . deny_reason . is_some ( ) {
return Err ( LemmyError ::from_message ( "registration_denied" ) ) ;
} else {
return Err ( LemmyError ::from_message ( "registration_application_pending" ) ) ;
}
}
Ok ( ( ) )
}