From 85dab149a93cd93dc5363fe5b8d51942385625b3 Mon Sep 17 00:00:00 2001 From: Louis GERARD Date: Tue, 4 Jul 2023 13:04:38 +0200 Subject: [PATCH] fix(posts/comments/search): return error on invalid community name (#3418) --- crates/apub/src/api/list_comments.rs | 4 +--- crates/apub/src/api/list_posts.rs | 4 +--- crates/apub/src/api/search.rs | 9 +++++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/apub/src/api/list_comments.rs b/crates/apub/src/api/list_comments.rs index 487aefa9..edb70dba 100644 --- a/crates/apub/src/api/list_comments.rs +++ b/crates/apub/src/api/list_comments.rs @@ -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::(name, &context, &None, true) - .await - .ok() + Some(resolve_actor_identifier::(name, &context, &None, true).await?) .map(|c| c.id) } else { data.community_id diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index bde373f6..ff7ac108 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -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::(name, &context, &None, true) - .await - .ok() + Some(resolve_actor_identifier::(name, &context, &None, true).await?) .map(|c| c.id) } else { data.community_id diff --git a/crates/apub/src/api/search.rs b/crates/apub/src/api/search.rs index 777a7013..0f9a6b37 100644 --- a/crates/apub/src/api/search.rs +++ b/crates/apub/src/api/search.rs @@ -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::(name, &context, &local_user_view, false) - .await - .ok() - .map(|c| c.id) + Some( + resolve_actor_identifier::(name, &context, &local_user_view, false) + .await?, + ) + .map(|c| c.id) } else { data.community_id }; -- 2.44.1