M openapi/openapi.json => openapi/openapi.json +7 -0
@@ 1108,6 1108,13 @@
"in": "query",
"required": false,
"schema": {"type": "string"}
+ },
+ {
+ "name": "in_any_local_community",
+ "in": "query",
+ "required": false,
+ "schema": {"type": "string"},
+ "description": "Filter by whether the post is approved in a local community"
}
],
"responses": {
M src/routes/api/posts.rs => src/routes/api/posts.rs +9 -1
@@ 132,7 132,7 @@ async fn route_unstable_posts_list(
#[derive(Deserialize)]
struct PostsListQuery<'a> {
- #[serde(default)]
+ in_any_local_community: Option<bool>,
search: Option<Cow<'a, str>>,
#[serde(default)]
@@ 178,6 178,14 @@ async fn route_unstable_posts_list(
search_value_idx = Some(values.len());
write!(sql, " AND to_tsvector('english', title || ' ' || COALESCE(content_text, content_markdown, content_html, '')) @@ plainto_tsquery('english', ${})", values.len()).unwrap();
}
+ if let Some(value) = query.in_any_local_community {
+ write!(
+ sql,
+ " AND {}(community.local AND post.approved)",
+ if value { "" } else { "NOT " }
+ )
+ .unwrap();
+ }
sql.push_str(" ORDER BY ");
match query.sort {
PostsListSortType::Normal(ty) => sql.push_str(ty.post_sort_sql()),