Fixing couldnt find community error.

dont_allow_posts_to_deleted_or_removed_communities
Dessalines 2021-10-11 22:19:55 -04:00
parent cd0574d277
commit 9909e18bd2
2 changed files with 4 additions and 2 deletions

View File

@ -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 () => {

View File

@ -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 {