Skip to content

Commit

Permalink
fix(posts/comments/search): return error on invalid community name (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis GERARD authored Jul 4, 2023
1 parent cdc5b47 commit 85dab14
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions crates/apub/src/api/list_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ pub async fn list_comments(
check_private_instance(&local_user_view, &local_site)?;

let community_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true)
.await
.ok()
Some(resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true).await?)
.map(|c| c.id)
} else {
data.community_id
Expand Down
4 changes: 1 addition & 3 deletions crates/apub/src/api/list_posts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ pub async fn list_posts(
let page = data.page;
let limit = data.limit;
let community_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true)
.await
.ok()
Some(resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &None, true).await?)
.map(|c| c.id)
} else {
data.community_id
Expand Down
9 changes: 5 additions & 4 deletions crates/apub/src/api/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ pub async fn search(
let listing_type = data.listing_type;
let search_type = data.type_.unwrap_or(SearchType::All);
let community_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, false)
.await
.ok()
.map(|c| c.id)
Some(
resolve_actor_identifier::<ApubCommunity, Community>(name, &context, &local_user_view, false)
.await?,
)
.map(|c| c.id)
} else {
data.community_id
};
Expand Down

0 comments on commit 85dab14

Please sign in to comment.