From: Louis GERARD Date: Tue, 4 Jul 2023 11:04:38 +0000 (+0200) Subject: fix(posts/comments/search): return error on invalid community name (#3418) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/static/sneer-club-logo.svg?a=commitdiff_plain;h=85dab149a93cd93dc5363fe5b8d51942385625b3;p=lemmy.git fix(posts/comments/search): return error on invalid community name (#3418) --- 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 };