]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/api/list_posts.rs
Remove TypedBuilder from db_views and db_views_actor (#3637)
[lemmy.git] / crates / apub / src / api / list_posts.rs
index 63d6800e8703af84fe517857739b69e2343802a6..c60abc966017b5bb6ade4fc39fe322d7e0c78c82 100644 (file)
@@ -36,27 +36,32 @@ pub async fn list_posts(
   };
   let saved_only = data.saved_only;
 
-  let listing_type = listing_type_with_default(data.type_, &local_site, community_id)?;
+  let listing_type = Some(listing_type_with_default(
+    data.type_,
+    &local_site,
+    community_id,
+  )?);
 
-  let is_mod_or_admin =
+  let is_mod_or_admin = Some(
     is_mod_or_admin_opt(&mut context.pool(), local_user_view.as_ref(), community_id)
       .await
-      .is_ok();
-
-  let posts = PostQuery::builder()
-    .pool(&mut context.pool())
-    .local_user(local_user_view.map(|l| l.local_user).as_ref())
-    .listing_type(Some(listing_type))
-    .sort(sort)
-    .community_id(community_id)
-    .saved_only(saved_only)
-    .page(page)
-    .limit(limit)
-    .is_mod_or_admin(Some(is_mod_or_admin))
-    .build()
-    .list()
-    .await
-    .with_lemmy_type(LemmyErrorType::CouldntGetPosts)?;
+      .is_ok(),
+  );
+
+  let posts = PostQuery {
+    local_user: local_user_view.map(|l| l.local_user).as_ref(),
+    listing_type,
+    sort,
+    community_id,
+    saved_only,
+    page,
+    limit,
+    is_mod_or_admin,
+    ..Default::default()
+  }
+  .list(&mut context.pool())
+  .await
+  .with_lemmy_type(LemmyErrorType::CouldntGetPosts)?;
 
   Ok(Json(GetPostsResponse { posts }))
 }