my_user_id: Option<i32>,
for_creator_id: Option<i32>,
for_community_id: Option<i32>,
+ for_community_name: Option<String>,
search_term: Option<String>,
url_search: Option<String>,
show_nsfw: bool,
my_user_id: None,
for_creator_id: None,
for_community_id: None,
+ for_community_name: None,
search_term: None,
url_search: None,
show_nsfw: true,
self
}
+ pub fn for_community_name<T: MaybeOptional<String>>(mut self, for_community_name: T) -> Self {
+ self.for_community_name = for_community_name.get_optional();
+ self
+ }
+
pub fn for_creator_id<T: MaybeOptional<i32>>(mut self, for_creator_id: T) -> Self {
self.for_creator_id = for_creator_id.get_optional();
self
query = query.then_order_by(stickied.desc());
}
+ if let Some(for_community_name) = self.for_community_name {
+ query = query.filter(community_name.eq(for_community_name));
+ query = query.then_order_by(stickied.desc());
+ }
+
if let Some(url_search) = self.url_search {
query = query.filter(url.eq(url_search));
}
Saveable,
SortType,
};
-use lemmy_utils::{is_valid_post_title, make_apub_endpoint, slur_check, slurs_vec_to_str, EndpointType};
+use lemmy_utils::{
+ is_valid_post_title,
+ make_apub_endpoint,
+ slur_check,
+ slurs_vec_to_str,
+ EndpointType,
+};
use serde::{Deserialize, Serialize};
use std::str::FromStr;
page: Option<i64>,
limit: Option<i64>,
pub community_id: Option<i32>,
+ pub community_name: Option<String>,
auth: Option<String>,
}
let page = data.page;
let limit = data.limit;
let community_id = data.community_id;
+ let community_name = data.community_name.to_owned();
let posts = match blocking(pool, move |conn| {
PostQueryBuilder::create(conn)
.listing_type(type_)
.sort(&sort)
.show_nsfw(show_nsfw)
.for_community_id(community_id)
+ .for_community_name(community_name)
.my_user_id(user_id)
.page(page)
.limit(limit)