use crate::PerformCrud;
use actix_web::web::Data;
use lemmy_api_common::{
- blocking,
- honeypot_check,
- password_length_check,
- person::*,
- send_verification_email,
+ person::{LoginResponse, Register},
+ utils::{blocking, honeypot_check, password_length_check, send_verification_email},
};
use lemmy_apub::{
generate_followers_url,
EndpointType,
};
use lemmy_db_schema::{
+ aggregates::structs::PersonAggregates,
newtypes::CommunityId,
source::{
community::{
},
traits::{Crud, Followable, Joinable},
};
-use lemmy_db_views_actor::person_view::PersonViewSafe;
+use lemmy_db_views::structs::LocalUserView;
+use lemmy_db_views_actor::structs::PersonViewSafe;
use lemmy_utils::{
apub::generate_actor_keypair,
claims::Claims,
Person::create(conn, &person_form)
})
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("user_already_exists"))?;
+ .map_err(|e| LemmyError::from_error_message(e, "user_already_exists"))?;
// Create the local user
let local_user_form = LocalUserForm {
})
.await??;
- return Err(LemmyError::from(e).with_message(err_type));
+ return Err(LemmyError::from_error_message(e, err_type));
}
};
let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form);
blocking(context.pool(), follow)
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("community_follower_already_exists"))?;
+ .map_err(|e| LemmyError::from_error_message(e, "community_follower_already_exists"))?;
// If its an admin, add them as a mod and follower to main
if no_admins {
let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
blocking(context.pool(), join)
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("community_moderator_already_exists"))?;
+ .map_err(|e| LemmyError::from_error_message(e, "community_moderator_already_exists"))?;
}
let mut login_response = LoginResponse {
);
} else {
if email_verification {
+ let local_user_view = LocalUserView {
+ local_user: inserted_local_user,
+ person: inserted_person,
+ counts: PersonAggregates::default(),
+ };
+ // we check at the beginning of this method that email is set
+ let email = local_user_view
+ .local_user
+ .email
+ .clone()
+ .expect("email was provided");
send_verification_email(
- inserted_local_user.id,
- // we check at the beginning of this method that email is set
- &inserted_local_user.email.expect("email was provided"),
- &inserted_person.name,
+ &local_user_view,
+ &email,
context.pool(),
&context.settings(),
)