]> Untitled Git - lemmy.git/commitdiff
Dont make webfinger request when viewing community/user profile (fixes #1896) (#2049)
authorNutomic <me@nutomic.com>
Thu, 27 Jan 2022 16:39:22 +0000 (16:39 +0000)
committerGitHub <noreply@github.com>
Thu, 27 Jan 2022 16:39:22 +0000 (16:39 +0000)
19 files changed:
Cargo.lock
crates/api/src/site.rs
crates/api_common/Cargo.toml
crates/api_common/src/lib.rs
crates/api_crud/src/comment/read.rs
crates/api_crud/src/community/read.rs
crates/api_crud/src/post/read.rs
crates/api_crud/src/user/read.rs
crates/apub/src/fetcher/search.rs
crates/apub/src/fetcher/webfinger.rs
crates/apub/src/http/community.rs
crates/apub/src/http/person.rs
crates/apub/src/objects/community.rs
crates/apub/src/objects/person.rs
crates/db_schema/src/impls/community.rs
crates/db_schema/src/impls/person.rs
crates/db_schema/src/traits.rs
crates/routes/src/feeds.rs
crates/routes/src/webfinger.rs

index 11ca872b2d52a08dfea152721ec878455bc51f3b..4d33d21fe62e1fb644e863f6938a602543edcfcb 100644 (file)
@@ -1847,6 +1847,7 @@ dependencies = [
  "actix-web",
  "chrono",
  "diesel",
+ "itertools",
  "lemmy_db_schema",
  "lemmy_db_views",
  "lemmy_db_views_actor",
index c77b177fab31d8a2a90d3ce5e3d052a2e2aed3dd..20ceffe57b2455a274fee4dad55b36fa7076f9b9 100644 (file)
@@ -8,22 +8,17 @@ use lemmy_api_common::{
   get_local_user_view_from_jwt,
   get_local_user_view_from_jwt_opt,
   is_admin,
+  resolve_actor_identifier,
   send_application_approved_email,
   site::*,
 };
-use lemmy_apub::{
-  fetcher::{
-    search::{search_by_apub_id, SearchableObjects},
-    webfinger::webfinger_resolve,
-  },
-  objects::community::ApubCommunity,
-  EndpointType,
-};
+use lemmy_apub::fetcher::search::{search_by_apub_id, SearchableObjects};
 use lemmy_db_schema::{
   diesel_option_overwrite,
   from_opt_str_to_opt_enum,
   newtypes::PersonId,
   source::{
+    community::Community,
     local_user::{LocalUser, LocalUserForm},
     moderator::*,
     person::Person,
@@ -195,9 +190,10 @@ impl Perform for Search {
     let search_type: SearchType = from_opt_str_to_opt_enum(&data.type_).unwrap_or(SearchType::All);
     let community_id = data.community_id;
     let community_actor_id = if let Some(name) = &data.community_name {
-      webfinger_resolve::<ApubCommunity>(name, EndpointType::Community, context, &mut 0)
+      resolve_actor_identifier::<Community>(name, context.pool())
         .await
         .ok()
+        .map(|c| c.actor_id)
     } else {
       None
     };
index 44e8aa2513957f370fd261d718ec26156194ef4b..368432937f92b406fc805b7dee55d64d35de9748 100644 (file)
@@ -25,3 +25,4 @@ chrono = { version = "0.4.19", features = ["serde"] }
 serde_json = { version = "1.0.72", features = ["preserve_order"] }
 tracing = "0.1.29"
 url = "2.2.2"
+itertools = "0.10.3"
index a83f0071b300251b45ade975ca7203b3efde491b..2d1f1bf5047ce904ec720596bb5cac70cd93e704 100644 (file)
@@ -6,6 +6,7 @@ pub mod site;
 pub mod websocket;
 
 use crate::site::FederatedInstances;
+use itertools::Itertools;
 use lemmy_db_schema::{
   newtypes::{CommunityId, LocalUserId, PersonId, PostId},
   source::{
@@ -18,7 +19,7 @@ use lemmy_db_schema::{
     secret::Secret,
     site::Site,
   },
-  traits::{Crud, Readable},
+  traits::{ApubActor, Crud, Readable},
   DbPool,
 };
 use lemmy_db_views::local_user_view::{LocalUserSettingsView, LocalUserView};
@@ -521,3 +522,36 @@ pub async fn check_private_instance_and_federation_enabled(
   }
   Ok(())
 }
+
+/// Resolve actor identifier (eg `!news@example.com`) from local database to avoid network requests.
+/// This only works for local actors, and remote actors which were previously fetched (so it doesnt
+/// trigger any new fetch).
+#[tracing::instrument(skip_all)]
+pub async fn resolve_actor_identifier<Actor>(
+  identifier: &str,
+  pool: &DbPool,
+) -> Result<Actor, LemmyError>
+where
+  Actor: ApubActor + Send + 'static,
+{
+  // remote actor
+  if identifier.contains('@') {
+    let (name, domain) = identifier
+      .splitn(2, '@')
+      .collect_tuple()
+      .expect("invalid query");
+    let name = name.to_string();
+    let domain = format!("{}://{}", Settings::get().get_protocol_string(), domain);
+    Ok(
+      blocking(pool, move |conn| {
+        Actor::read_from_name_and_domain(conn, &name, &domain)
+      })
+      .await??,
+    )
+  }
+  // local actor
+  else {
+    let identifier = identifier.to_string();
+    Ok(blocking(pool, move |conn| Actor::read_from_name(conn, &identifier)).await??)
+  }
+}
index 459469917e442242436ad99b40d794f7c304bc80..56584fc37bf0d2b1040df58432ffa7fe6631c82a 100644 (file)
@@ -5,14 +5,11 @@ use lemmy_api_common::{
   check_private_instance,
   comment::*,
   get_local_user_view_from_jwt_opt,
-};
-use lemmy_apub::{
-  fetcher::webfinger::webfinger_resolve,
-  objects::community::ApubCommunity,
-  EndpointType,
+  resolve_actor_identifier,
 };
 use lemmy_db_schema::{
   from_opt_str_to_opt_enum,
+  source::community::Community,
   traits::DeleteableOrRemoveable,
   ListingType,
   SortType,
@@ -82,9 +79,10 @@ impl PerformCrud for GetComments {
 
     let community_id = data.community_id;
     let community_actor_id = if let Some(name) = &data.community_name {
-      webfinger_resolve::<ApubCommunity>(name, EndpointType::Community, context, &mut 0)
+      resolve_actor_identifier::<Community>(name, context.pool())
         .await
         .ok()
+        .map(|c| c.actor_id)
     } else {
       None
     };
index 2ec4054b25e30ad4cd49bbaca9a85489cf3663c9..7e61bfa717f293359f65c4006e828ab99185c6e8 100644 (file)
@@ -5,15 +5,11 @@ use lemmy_api_common::{
   check_private_instance,
   community::*,
   get_local_user_view_from_jwt_opt,
+  resolve_actor_identifier,
 };
-use lemmy_apub::{
-  fetcher::webfinger::webfinger_resolve,
-  objects::community::ApubCommunity,
-  EndpointType,
-};
-use lemmy_apub_lib::object_id::ObjectId;
 use lemmy_db_schema::{
   from_opt_str_to_opt_enum,
+  source::community::Community,
   traits::DeleteableOrRemoveable,
   ListingType,
   SortType,
@@ -48,12 +44,7 @@ impl PerformCrud for GetCommunity {
       Some(id) => id,
       None => {
         let name = data.name.to_owned().unwrap_or_else(|| "main".to_string());
-        let community_actor_id =
-          webfinger_resolve::<ApubCommunity>(&name, EndpointType::Community, context, &mut 0)
-            .await?;
-
-        ObjectId::<ApubCommunity>::new(community_actor_id)
-          .dereference(context, context.client(), &mut 0)
+        resolve_actor_identifier::<Community>(&name, context.pool())
           .await
           .map_err(LemmyError::from)
           .map_err(|e| e.with_message("couldnt_find_community"))?
index 10ecefc38793a34d24bd87c6befd53f6de7aae08..8d049e70ae073db8a8b0a3e3a2ede219a891f610 100644 (file)
@@ -6,14 +6,11 @@ use lemmy_api_common::{
   get_local_user_view_from_jwt_opt,
   mark_post_as_read,
   post::*,
-};
-use lemmy_apub::{
-  fetcher::webfinger::webfinger_resolve,
-  objects::community::ApubCommunity,
-  EndpointType,
+  resolve_actor_identifier,
 };
 use lemmy_db_schema::{
   from_opt_str_to_opt_enum,
+  source::community::Community,
   traits::DeleteableOrRemoveable,
   ListingType,
   SortType,
@@ -157,9 +154,10 @@ impl PerformCrud for GetPosts {
     let limit = data.limit;
     let community_id = data.community_id;
     let community_actor_id = if let Some(name) = &data.community_name {
-      webfinger_resolve::<ApubCommunity>(name, EndpointType::Community, context, &mut 0)
+      resolve_actor_identifier::<Community>(name, context.pool())
         .await
         .ok()
+        .map(|c| c.actor_id)
     } else {
       None
     };
index efa058b184222031e515a11fe588c92f6ad486ea..9368fabdfdf13771d38066be0e9ad9a223be3f72 100644 (file)
@@ -5,14 +5,9 @@ use lemmy_api_common::{
   check_private_instance,
   get_local_user_view_from_jwt_opt,
   person::*,
+  resolve_actor_identifier,
 };
-use lemmy_apub::{
-  fetcher::webfinger::webfinger_resolve,
-  objects::person::ApubPerson,
-  EndpointType,
-};
-use lemmy_apub_lib::object_id::ObjectId;
-use lemmy_db_schema::{from_opt_str_to_opt_enum, SortType};
+use lemmy_db_schema::{from_opt_str_to_opt_enum, source::person::Person, SortType};
 use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
 use lemmy_db_views_actor::{
   community_moderator_view::CommunityModeratorView,
@@ -55,13 +50,9 @@ impl PerformCrud for GetPersonDetails {
           .username
           .to_owned()
           .unwrap_or_else(|| "admin".to_string());
-        let actor_id =
-          webfinger_resolve::<ApubPerson>(&name, EndpointType::Person, context, &mut 0).await?;
 
-        let person = ObjectId::<ApubPerson>::new(actor_id)
-          .dereference(context, context.client(), &mut 0)
-          .await;
-        person
+        resolve_actor_identifier::<Person>(&name, context.pool())
+          .await
           .map_err(LemmyError::from)
           .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))?
           .id
index 8c53c25c7da64791bb5a8d7a4538f2ffa0d04d21..6271cec12ca3745193cb3b337df346965c4a8ea9 100644 (file)
@@ -1,8 +1,7 @@
 use crate::{
-  fetcher::webfinger::webfinger_resolve,
+  fetcher::webfinger::webfinger_resolve_actor,
   objects::{comment::ApubComment, community::ApubCommunity, person::ApubPerson, post::ApubPost},
   protocol::objects::{group::Group, note::Note, page::Page, person::Person},
-  EndpointType,
 };
 use chrono::NaiveDateTime;
 use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject};
@@ -34,13 +33,8 @@ pub async fn search_by_apub_id(
       let (kind, identifier) = query.split_at(1);
       match kind {
         "@" => {
-          let id = webfinger_resolve::<ApubPerson>(
-            identifier,
-            EndpointType::Person,
-            context,
-            request_counter,
-          )
-          .await?;
+          let id =
+            webfinger_resolve_actor::<ApubPerson>(identifier, context, request_counter).await?;
           Ok(SearchableObjects::Person(
             ObjectId::new(id)
               .dereference(context, context.client(), request_counter)
@@ -48,13 +42,8 @@ pub async fn search_by_apub_id(
           ))
         }
         "!" => {
-          let id = webfinger_resolve::<ApubCommunity>(
-            identifier,
-            EndpointType::Community,
-            context,
-            request_counter,
-          )
-          .await?;
+          let id =
+            webfinger_resolve_actor::<ApubCommunity>(identifier, context, request_counter).await?;
           Ok(SearchableObjects::Community(
             ObjectId::new(id)
               .dereference(context, context.client(), request_counter)
index e623bee22496df70542a7f537f6b91e1e19a734a..d039c1c1744158c6a5d7295aacb8496d07859c26 100644 (file)
@@ -1,4 +1,3 @@
-use crate::{generate_local_apub_endpoint, EndpointType};
 use itertools::Itertools;
 use lemmy_apub_lib::{
   object_id::ObjectId,
@@ -28,37 +27,6 @@ pub struct WebfingerResponse {
   pub links: Vec<WebfingerLink>,
 }
 
-/// Takes in a shortname of the type dessalines@xyz.tld or dessalines (assumed to be local), and
-/// outputs the actor id. Used in the API for communities and users.
-///
-/// TODO: later provide a method in ApubObject to generate the endpoint, so that we dont have to
-///       pass in EndpointType
-#[tracing::instrument(skip_all)]
-pub async fn webfinger_resolve<Kind>(
-  identifier: &str,
-  endpoint_type: EndpointType,
-  context: &LemmyContext,
-  request_counter: &mut i32,
-) -> Result<DbUrl, LemmyError>
-where
-  Kind: ApubObject<DataType = LemmyContext> + ActorType + Send + 'static,
-  for<'de2> <Kind as ApubObject>::ApubType: serde::Deserialize<'de2>,
-{
-  // remote actor
-  if identifier.contains('@') {
-    webfinger_resolve_actor::<Kind>(identifier, context, request_counter).await
-  }
-  // local actor
-  else {
-    let domain = context.settings().get_protocol_and_hostname();
-    Ok(generate_local_apub_endpoint(
-      endpoint_type,
-      identifier,
-      &domain,
-    )?)
-  }
-}
-
 /// Turns a person id like `@name@example.com` into an apub ID, like `https://example.com/user/name`,
 /// using webfinger.
 #[tracing::instrument(skip_all)]
index 9e1cb2779c2bb81e5bdc44dde06129088b170348..5483d58d14171de8c17b5ce9dd75b7367de262ee 100644 (file)
@@ -24,7 +24,7 @@ use crate::{
 use actix_web::{web, web::Payload, HttpRequest, HttpResponse};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject};
-use lemmy_db_schema::source::community::Community;
+use lemmy_db_schema::{source::community::Community, traits::ApubActor};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
 use serde::Deserialize;
index 131c90404d0b06baba5f347457b0be33e541a59d..bc0633d8d58e071832e4dcaa3f68eefb8d17ef64 100644 (file)
@@ -14,7 +14,7 @@ use crate::{
 use actix_web::{web, web::Payload, HttpRequest, HttpResponse};
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::traits::ApubObject;
-use lemmy_db_schema::source::person::Person;
+use lemmy_db_schema::{source::person::Person, traits::ApubActor};
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
 use serde::Deserialize;
@@ -34,7 +34,7 @@ pub(crate) async fn get_apub_person_http(
   let user_name = info.into_inner().user_name;
   // TODO: this needs to be able to read deleted persons, so that it can send tombstones
   let person: ApubPerson = blocking(context.pool(), move |conn| {
-    Person::find_by_name(conn, &user_name)
+    Person::read_from_name(conn, &user_name)
   })
   .await??
   .into();
@@ -77,7 +77,7 @@ pub(crate) async fn get_apub_person_outbox(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse, LemmyError> {
   let person = blocking(context.pool(), move |conn| {
-    Person::find_by_name(conn, &info.user_name)
+    Person::read_from_name(conn, &info.user_name)
   })
   .await??;
   let outbox = PersonOutbox::new(person).await?;
index 65b0e64b1bd2d2bd5801702458d3a5baec2fb538..cce61b57f25940606a178f56f9856122bfcb2b4c 100644 (file)
@@ -18,7 +18,7 @@ use lemmy_apub_lib::{
   traits::{ActorType, ApubObject},
   values::MediaTypeMarkdown,
 };
-use lemmy_db_schema::source::community::Community;
+use lemmy_db_schema::{source::community::Community, traits::ApubActor};
 use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
 use lemmy_utils::{
   utils::{convert_datetime, markdown_to_html},
index f6ad0e2070972ae23905853b5a32e5466b2fccc4..21f0f248c52c15aca448cfbcd73e474a2b249e8c 100644 (file)
@@ -22,6 +22,7 @@ use lemmy_apub_lib::{
 use lemmy_db_schema::{
   naive_now,
   source::person::{Person as DbPerson, PersonForm},
+  traits::ApubActor,
 };
 use lemmy_utils::{
   utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html},
index 228cf23ffdba4fadedc1c6f19ee81a42bdcd8e9e..d2b0d9cdebfee641f9863ccb73f88ba352a311e5 100644 (file)
@@ -13,9 +13,17 @@ use crate::{
     CommunityPersonBanForm,
     CommunitySafe,
   },
-  traits::{Bannable, Crud, DeleteableOrRemoveable, Followable, Joinable},
+  traits::{ApubActor, Bannable, Crud, DeleteableOrRemoveable, Followable, Joinable},
+};
+use diesel::{
+  dsl::*,
+  result::Error,
+  ExpressionMethods,
+  PgConnection,
+  QueryDsl,
+  RunQueryDsl,
+  TextExpressionMethods,
 };
-use diesel::{dsl::*, result::Error, ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
 use url::Url;
 
 mod safe_type {
@@ -92,14 +100,6 @@ impl Crud for Community {
 }
 
 impl Community {
-  pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
-    use crate::schema::community::dsl::*;
-    community
-      .filter(local.eq(true))
-      .filter(lower(name).eq(lower(community_name)))
-      .first::<Self>(conn)
-  }
-
   pub fn update_deleted(
     conn: &PgConnection,
     community_id: CommunityId,
@@ -136,17 +136,6 @@ impl Community {
       .set(community_form)
       .get_result::<Self>(conn)
   }
-  pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
-    use crate::schema::community::dsl::*;
-    let object_id: DbUrl = object_id.into();
-    Ok(
-      community
-        .filter(actor_id.eq(object_id))
-        .first::<Community>(conn)
-        .ok()
-        .map(Into::into),
-    )
-  }
 }
 
 impl Joinable for CommunityModerator {
@@ -299,6 +288,40 @@ impl Followable for CommunityFollower {
   }
 }
 
+impl ApubActor for Community {
+  fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
+    use crate::schema::community::dsl::*;
+    let object_id: DbUrl = object_id.into();
+    Ok(
+      community
+        .filter(actor_id.eq(object_id))
+        .first::<Community>(conn)
+        .ok()
+        .map(Into::into),
+    )
+  }
+
+  fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
+    use crate::schema::community::dsl::*;
+    community
+      .filter(local.eq(true))
+      .filter(lower(name).eq(lower(community_name)))
+      .first::<Self>(conn)
+  }
+
+  fn read_from_name_and_domain(
+    conn: &PgConnection,
+    community_name: &str,
+    protocol_domain: &str,
+  ) -> Result<Community, Error> {
+    use crate::schema::community::dsl::*;
+    community
+      .filter(lower(name).eq(lower(community_name)))
+      .filter(actor_id.like(format!("{}%", protocol_domain)))
+      .first::<Self>(conn)
+  }
+}
+
 #[cfg(test)]
 mod tests {
   use crate::{
index 17833253bcc0083b7f4967b1f7623b7c1aa3049b..4c052c8b61eb549326d0b067f2d52cde68d4cfa3 100644 (file)
@@ -4,9 +4,17 @@ use crate::{
   newtypes::{DbUrl, PersonId},
   schema::person::dsl::*,
   source::person::{Person, PersonForm, PersonSafe},
-  traits::Crud,
+  traits::{ApubActor, Crud},
+};
+use diesel::{
+  dsl::*,
+  result::Error,
+  ExpressionMethods,
+  PgConnection,
+  QueryDsl,
+  RunQueryDsl,
+  TextExpressionMethods,
 };
-use diesel::{dsl::*, result::Error, ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
 use url::Url;
 
 mod safe_type {
@@ -202,14 +210,6 @@ impl Person {
       .get_result::<Self>(conn)
   }
 
-  pub fn find_by_name(conn: &PgConnection, from_name: &str) -> Result<Person, Error> {
-    person
-      .filter(deleted.eq(false))
-      .filter(local.eq(true))
-      .filter(lower(name).eq(lower(from_name)))
-      .first::<Person>(conn)
-  }
-
   pub fn mark_as_updated(conn: &PgConnection, person_id: PersonId) -> Result<Person, Error> {
     diesel::update(person.find(person_id))
       .set((last_refreshed_at.eq(naive_now()),))
@@ -247,19 +247,6 @@ impl Person {
       .get_result::<Self>(conn)
   }
 
-  pub fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
-    use crate::schema::person::dsl::*;
-    let object_id: DbUrl = object_id.into();
-    Ok(
-      person
-        .filter(deleted.eq(false))
-        .filter(actor_id.eq(object_id))
-        .first::<Person>(conn)
-        .ok()
-        .map(Into::into),
-    )
-  }
-
   pub fn update_deleted(
     conn: &PgConnection,
     person_id: PersonId,
@@ -296,6 +283,41 @@ fn is_banned(banned_: bool, expires: Option<chrono::NaiveDateTime>) -> bool {
   }
 }
 
+impl ApubActor for Person {
+  fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error> {
+    use crate::schema::person::dsl::*;
+    let object_id: DbUrl = object_id.into();
+    Ok(
+      person
+        .filter(deleted.eq(false))
+        .filter(actor_id.eq(object_id))
+        .first::<Person>(conn)
+        .ok()
+        .map(Into::into),
+    )
+  }
+
+  fn read_from_name(conn: &PgConnection, from_name: &str) -> Result<Person, Error> {
+    person
+      .filter(deleted.eq(false))
+      .filter(local.eq(true))
+      .filter(lower(name).eq(lower(from_name)))
+      .first::<Person>(conn)
+  }
+
+  fn read_from_name_and_domain(
+    conn: &PgConnection,
+    person_name: &str,
+    protocol_domain: &str,
+  ) -> Result<Person, Error> {
+    use crate::schema::person::dsl::*;
+    person
+      .filter(lower(name).eq(lower(person_name)))
+      .filter(actor_id.like(format!("{}%", protocol_domain)))
+      .first::<Self>(conn)
+  }
+}
+
 #[cfg(test)]
 mod tests {
   use crate::{establish_unpooled_connection, source::person::*, traits::Crud};
index aea36ed87a523f438620bdf7691d55c01e46b25e..ad984d7bf5a00b00c2a6098f941abeb455c7382b 100644 (file)
@@ -1,5 +1,6 @@
 use crate::newtypes::{CommunityId, PersonId};
 use diesel::{result::Error, PgConnection};
+use url::Url;
 
 pub trait Crud {
   type Form;
@@ -162,3 +163,20 @@ pub trait ViewToVec {
   where
     Self: Sized;
 }
+
+pub trait ApubActor {
+  // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
+  fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error>
+  where
+    Self: Sized;
+  fn read_from_name(conn: &PgConnection, actor_name: &str) -> Result<Self, Error>
+  where
+    Self: Sized;
+  fn read_from_name_and_domain(
+    conn: &PgConnection,
+    actor_name: &str,
+    protocol_domain: &str,
+  ) -> Result<Self, Error>
+  where
+    Self: Sized;
+}
index 7b668d7ebee0f61baa4d548bd43b6ff964de8825..9538f06c0ede0f056d18980650c9846ead144774 100644 (file)
@@ -6,7 +6,7 @@ use lemmy_api_common::blocking;
 use lemmy_db_schema::{
   newtypes::LocalUserId,
   source::{community::Community, local_user::LocalUser, person::Person},
-  traits::Crud,
+  traits::{ApubActor, Crud},
   ListingType,
   SortType,
 };
@@ -175,7 +175,7 @@ fn get_feed_user(
   protocol_and_hostname: &str,
 ) -> Result<ChannelBuilder, LemmyError> {
   let site_view = SiteView::read(conn)?;
-  let person = Person::find_by_name(conn, user_name)?;
+  let person = Person::read_from_name(conn, user_name)?;
 
   let posts = PostQueryBuilder::create(conn)
     .listing_type(ListingType::All)
index 82b8a619e94bea2266308432e982ad0633ec4c1a..b315537937f9261459bc7b39b7155dbd9fccbf94 100644 (file)
@@ -2,7 +2,10 @@ use actix_web::{web, web::Query, HttpResponse};
 use anyhow::Context;
 use lemmy_api_common::blocking;
 use lemmy_apub::fetcher::webfinger::{WebfingerLink, WebfingerResponse};
-use lemmy_db_schema::source::{community::Community, person::Person};
+use lemmy_db_schema::{
+  source::{community::Community, person::Person},
+  traits::ApubActor,
+};
 use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
 use lemmy_websocket::LemmyContext;
 use serde::Deserialize;
@@ -44,7 +47,7 @@ async fn get_webfinger_response(
 
   let name_ = name.clone();
   let user_id: Option<Url> = blocking(context.pool(), move |conn| {
-    Person::find_by_name(conn, &name_)
+    Person::read_from_name(conn, &name_)
   })
   .await?
   .ok()