summaryrefslogtreecommitdiffstats
path: root/server/src/api/post.rs
diff options
context:
space:
mode:
authorLyra <teromene@teromene.fr>2019-12-07 13:03:03 +0100
committerLyra <teromene@teromene.fr>2019-12-07 13:03:03 +0100
commitbff3183a2701257ce085a76d9d5d327f80ccec37 (patch)
treebd2a86ad62af866a8b0fe89f4bcc278f6e05d37e /server/src/api/post.rs
parent0ceed8fd9bd204533dacf3b79be1e0d97f33ed3e (diff)
Use a dedicated structure in order to search posts
Diffstat (limited to 'server/src/api/post.rs')
-rw-r--r--server/src/api/post.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/server/src/api/post.rs b/server/src/api/post.rs
index 5df42990..e507aba3 100644
--- a/server/src/api/post.rs
+++ b/server/src/api/post.rs
@@ -238,21 +238,13 @@ impl Perform<GetPostsResponse> for Oper<GetPosts> {
let type_ = ListingType::from_str(&data.type_)?;
let sort = SortType::from_str(&data.sort)?;
- let posts = match PostView::list(
- &conn,
- type_,
- &sort,
- data.community_id,
- None,
- None,
- None,
- user_id,
- show_nsfw,
- false,
- false,
- data.page,
- data.limit,
- ) {
+ let posts = match PostViewQuery::create(&conn, type_, &sort, show_nsfw, false, false)
+ .for_community_id_optional(data.community_id)
+ .my_user_id_optional(user_id)
+ .page_optional(data.page)
+ .limit_optional(data.limit)
+ .list()
+ {
Ok(posts) => posts,
Err(_e) => return Err(APIError::err(&self.op, "couldnt_get_posts"))?,
};