summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
authorDessalines <dessalines@users.noreply.github.com>2020-07-13 09:50:13 -0400
committerGitHub <noreply@github.com>2020-07-13 09:50:13 -0400
commit7556f8615fb859a400595960484da11da3d2ce41 (patch)
treedde5a0872850b06698c5e93d31bbbcb80470f673 /server/src/api/post.rs
parenta7c1c472fea9ff860b62ad25113cfed0f0d8e0bf (diff)
Adding a community_name option to GetPosts /post/list . Fixes #800 (#942)
Diffstat (limited to 'server/src/api/post.rs')
-rw-r--r--server/src/api/post.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/server/src/api/post.rs b/server/src/api/post.rs
index cbdb976c..6710a2cd 100644
--- a/server/src/api/post.rs
+++ b/server/src/api/post.rs
@@ -28,7 +28,13 @@ use lemmy_db::{
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;
@@ -70,6 +76,7 @@ pub struct GetPosts {
page: Option<i64>,
limit: Option<i64>,
pub community_id: Option<i32>,
+ pub community_name: Option<String>,
auth: Option<String>,
}
@@ -369,12 +376,14 @@ impl Perform for Oper<GetPosts> {
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)