fix(posts/comments/search): return error on invalid community name (#3418)
authorLouis GERARD <louis.gerard314@gmail.com>
Tue, 4 Jul 2023 11:04:38 +0000 (13:04 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Jul 2023 11:04:38 +0000 (13:04 +0200)
crates/apub/src/api/list_comments.rs
crates/apub/src/api/list_posts.rs
crates/apub/src/api/search.rs

index 487aefa9e6a4b081d61ab8a997f532a7c21be359..edb70dbaad1f52aa30b79b4d91ea0fc30c391741 100644 (file)
@@ -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
index bde373f655ce4545c03d65c6e9e374d54c0af027..ff7ac1089c43da5bda12caa4d164a9169bac3543 100644 (file)
@@ -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
index 777a7013be1604907f6c822de488c3efab2a1bd6..0f9a6b37fb153575cf1ec6802d3bb09e24744d39 100644 (file)
@@ -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
   };