is_admin,
site::*,
};
-use lemmy_apub::fetcher::search::search_by_apub_id;
+use lemmy_apub::{build_actor_id_from_shortname, fetcher::search::search_by_apub_id, EndpointType};
use lemmy_db_queries::{
from_opt_str_to_opt_enum,
source::site::Site_,
let listing_type: Option<ListingType> = from_opt_str_to_opt_enum(&data.listing_type);
let search_type: SearchType = from_opt_str_to_opt_enum(&data.type_).unwrap_or(SearchType::All);
let community_id = data.community_id;
- let community_name = data.community_name.to_owned();
+ let community_actor_id = data
+ .community_name
+ .as_ref()
+ .map(|t| build_actor_id_from_shortname(EndpointType::Community, t).ok())
+ .unwrap_or(None);
let creator_id = data.creator_id;
match search_type {
SearchType::Posts => {
.show_read_posts(show_read_posts)
.listing_type(listing_type)
.community_id(community_id)
- .community_name(community_name)
+ .community_actor_id(community_actor_id)
.creator_id(creator_id)
.my_person_id(person_id)
.search_term(q)
.search_term(q)
.show_bot_accounts(show_bot_accounts)
.community_id(community_id)
- .community_name(community_name)
+ .community_actor_id(community_actor_id)
.creator_id(creator_id)
.my_person_id(person_id)
.page(page)
// If the community or creator is included, dont search communities or users
let community_or_creator_included =
data.community_id.is_some() || data.community_name.is_some() || data.creator_id.is_some();
+ let community_actor_id_2 = community_actor_id.to_owned();
posts = blocking(context.pool(), move |conn| {
PostQueryBuilder::create(conn)
.show_read_posts(show_read_posts)
.listing_type(listing_type)
.community_id(community_id)
- .community_name(community_name)
+ .community_actor_id(community_actor_id_2)
.creator_id(creator_id)
.my_person_id(person_id)
.search_term(q)
.await??;
let q = data.q.to_owned();
- let community_name = data.community_name.to_owned();
+ let community_actor_id = community_actor_id.to_owned();
comments = blocking(context.pool(), move |conn| {
CommentQueryBuilder::create(conn)
.search_term(q)
.show_bot_accounts(show_bot_accounts)
.community_id(community_id)
- .community_name(community_name)
+ .community_actor_id(community_actor_id)
.creator_id(creator_id)
.my_person_id(person_id)
.page(page)
.listing_type(listing_type)
.my_person_id(person_id)
.community_id(community_id)
- .community_name(community_name)
+ .community_actor_id(community_actor_id)
.creator_id(creator_id)
.url_search(q)
.page(page)