diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 507262047..280396b00 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -90,7 +90,7 @@ test('Create a post', async () => { test('Create a post in a non-existent community', async () => { let postRes = await createPost(alpha, -2); - expect(postRes).toStrictEqual({ error: 'couldnt_create_post' }); + expect(postRes).toStrictEqual({ error: 'couldnt_find_community' }); }); test('Unlike a post', async () => { diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 11e3a0d12..be793afed 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -361,7 +361,9 @@ pub async fn check_community_deleted_or_removed( community_id: CommunityId, pool: &DbPool, ) -> Result<(), LemmyError> { - let community = blocking(pool, move |conn| Community::read(conn, community_id)).await??; + let community = blocking(pool, move |conn| Community::read(conn, community_id)) + .await? + .map_err(|_| ApiError::err("couldnt_find_community"))?; if community.deleted || community.removed { Err(ApiError::err("deleted").into()) } else {