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
lgerard-pass authored and dhawos committed Jun 30, 2023
1 parent 3159eed commit a81598a
Show file tree
Hide file tree
Showing 3 changed files with 12 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 @@ -28,9 +28,7 @@ impl PerformApub for GetComments {
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 @@ -30,9 +30,7 @@ impl PerformApub for GetPosts {
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
14 changes: 10 additions & 4 deletions crates/apub/src/api/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ impl PerformApub for 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 a81598a

Please sign in to comment.