|
|
|
@ -10,7 +10,7 @@ use lemmy_api_common::{
|
|
|
|
|
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_,
|
|
|
|
@ -167,7 +167,11 @@ impl Perform for Search {
|
|
|
|
|
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 => {
|
|
|
|
@ -179,7 +183,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
@ -197,7 +201,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
@ -234,6 +238,7 @@ impl Perform for Search {
|
|
|
|
|
// 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)
|
|
|
|
@ -243,7 +248,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
@ -254,7 +259,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
@ -263,7 +268,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
@ -316,7 +321,7 @@ impl Perform for Search {
|
|
|
|
|
.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)
|
|
|
|
|