is_deleted,
},
find_object_by_id,
- objects::{comment::Note, post::Page, FromApub},
- GroupExt,
+ objects::{comment::Note, community::Group, person::Person as ApubPerson, post::Page, FromApub},
Object,
- PersonExt,
};
-use activitystreams::base::BaseExt;
-use anyhow::{anyhow, Context};
+use anyhow::anyhow;
use lemmy_api_common::{blocking, site::SearchResponse};
use lemmy_db_queries::{
source::{
#[derive(serde::Deserialize, Debug)]
#[serde(untagged)]
enum SearchAcceptedObjects {
- Person(Box<PersonExt>),
- Group(Box<GroupExt>),
+ Person(Box<ApubPerson>),
+ Group(Box<Group>),
Page(Box<Page>),
Comment(Box<Note>),
}
recursion_counter: &mut i32,
context: &LemmyContext,
) -> Result<SearchResponse, LemmyError> {
- let domain = query_url.domain().context("url has no domain")?;
let mut response = SearchResponse {
type_: SearchType::All.to_string(),
comments: vec![],
match fetch_response {
SearchAcceptedObjects::Person(p) => {
- let person_uri = p.inner.id(domain)?.context("person has no id")?;
-
- let person = get_or_fetch_and_upsert_person(person_uri, context, recursion_counter).await?;
+ let person_id = p.id(&query_url)?;
+ let person = get_or_fetch_and_upsert_person(person_id, context, recursion_counter).await?;
response.users = vec![
blocking(context.pool(), move |conn| {
];
}
SearchAcceptedObjects::Group(g) => {
- let community_uri = g.inner.id(domain)?.context("group has no id")?;
-
+ let community_uri = g.id(&query_url)?;
let community =
get_or_fetch_and_upsert_community(community_uri, context, recursion_counter).await?;
];
}
SearchAcceptedObjects::Page(p) => {
- let p = Post::from_apub(&p, context, query_url, recursion_counter, false).await?;
+ let p = Post::from_apub(&p, context, &query_url, recursion_counter).await?;
response.posts =
vec![blocking(context.pool(), move |conn| PostView::read(conn, p.id, None)).await??];
}
SearchAcceptedObjects::Comment(c) => {
- let c = Comment::from_apub(&c, context, query_url, recursion_counter, false).await?;
+ let c = Comment::from_apub(&c, context, &query_url, recursion_counter).await?;
response.comments = vec![
blocking(context.pool(), move |conn| {