use crate::PerformCrud;
use actix_web::web::Data;
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, person::*};
-use lemmy_db_queries::{from_opt_str_to_opt_enum, source::person::Person_, SortType};
+use lemmy_apub::{build_actor_id_from_shortname, EndpointType};
+use lemmy_db_queries::{from_opt_str_to_opt_enum, ApubObject, SortType};
use lemmy_db_schema::source::person::*;
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
use lemmy_db_views_actor::{
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
- let username = data
- .username
- .to_owned()
- .unwrap_or_else(|| "admin".to_string());
let person_details_id = match data.person_id {
Some(id) => id,
None => {
+ let name = data
+ .username
+ .to_owned()
+ .unwrap_or_else(|| "admin".to_string());
+ let actor_id = build_actor_id_from_shortname(EndpointType::Person, &name)?;
+
let person = blocking(context.pool(), move |conn| {
- Person::find_by_name(conn, &username)
+ Person::read_from_apub_id(conn, &actor_id)
})
.await?;
person