user_show_nsfw,
};
use lemmy_apub::fetcher::search::search_by_apub_id;
-use lemmy_db_queries::{source::site::Site_, Crud, SearchType, SortType};
+use lemmy_db_queries::{source::site::Site_, Crud, ListingType, SearchType, SortType};
use lemmy_db_schema::source::{moderator::*, site::Site};
use lemmy_db_views::{
comment_view::CommentQueryBuilder,
let person_id = local_user_view.map(|u| u.person.id);
- let type_ = SearchType::from_str(&data.type_)?;
-
let mut posts = Vec::new();
let mut comments = Vec::new();
let mut communities = Vec::new();
let page = data.page;
let limit = data.limit;
let sort = SortType::from_str(&data.sort)?;
+ let type_ = SearchType::from_str(&data.type_)?;
+ let listing_type = ListingType::from_str(&data.listing_type)?;
let community_id = data.community_id;
let community_name = data.community_name.to_owned();
- let community_name_2 = data.community_name.to_owned();
let creator_id = data.creator_id;
match type_ {
SearchType::Posts => {
.sort(&sort)
.show_nsfw(show_nsfw)
.show_bot_accounts(show_bot_accounts)
+ .listing_type(&listing_type)
+ .show_nsfw(true)
.community_id(community_id)
.community_name(community_name)
.creator_id(creator_id)
comments = blocking(context.pool(), move |conn| {
CommentQueryBuilder::create(&conn)
.sort(&sort)
+ .listing_type(&listing_type)
.search_term(q)
.show_bot_accounts(show_bot_accounts)
.community_id(community_id)
communities = blocking(context.pool(), move |conn| {
CommunityQueryBuilder::create(conn)
.sort(&sort)
+ .listing_type(&listing_type)
.search_term(q)
.my_person_id(person_id)
.page(page)
.sort(&sort)
.show_nsfw(show_nsfw)
.show_bot_accounts(show_bot_accounts)
+ .listing_type(&listing_type)
+ .show_nsfw(true)
.community_id(community_id)
.community_name(community_name)
.creator_id(creator_id)
let q = data.q.to_owned();
let sort = SortType::from_str(&data.sort)?;
+ let listing_type = ListingType::from_str(&data.listing_type)?;
+ let community_name = data.community_name.to_owned();
comments = blocking(context.pool(), move |conn| {
CommentQueryBuilder::create(conn)
.sort(&sort)
+ .listing_type(&listing_type)
.search_term(q)
.show_bot_accounts(show_bot_accounts)
.community_id(community_id)
- .community_name(community_name_2)
+ .community_name(community_name)
.creator_id(creator_id)
.my_person_id(person_id)
.page(page)
let q = data.q.to_owned();
let sort = SortType::from_str(&data.sort)?;
+ let listing_type = ListingType::from_str(&data.listing_type)?;
communities = blocking(context.pool(), move |conn| {
CommunityQueryBuilder::create(conn)
.sort(&sort)
+ .listing_type(&listing_type)
.search_term(q)
.my_person_id(person_id)
.page(page)
.sort(&sort)
.show_nsfw(show_nsfw)
.show_bot_accounts(show_bot_accounts)
+ .listing_type(&listing_type)
+ .show_nsfw(true)
.my_person_id(person_id)
.community_id(community_id)
.community_name(community_name)
pub struct CommentQueryBuilder<'a> {
conn: &'a PgConnection,
- listing_type: ListingType,
+ listing_type: &'a ListingType,
sort: &'a SortType,
community_id: Option<CommunityId>,
community_name: Option<String>,
pub fn create(conn: &'a PgConnection) -> Self {
CommentQueryBuilder {
conn,
- listing_type: ListingType::All,
+ listing_type: &ListingType::All,
sort: &SortType::New,
community_id: None,
community_name: None,
}
}
- pub fn listing_type(mut self, listing_type: ListingType) -> Self {
+ pub fn listing_type(mut self, listing_type: &'a ListingType) -> Self {
self.listing_type = listing_type;
self
}