refactor: move unknown parent thread check

This commit is contained in:
agatha 2024-03-31 23:57:09 -04:00
parent 002fc63c90
commit 4228107b54

View File

@ -95,7 +95,9 @@ async def reply_to_post(thread_id: int, data: PostCreate):
if thread.id == thread_id: if thread.id == thread_id:
parent = thread parent = thread
if parent: if parent is None:
return {'error': 'could not find parent thread'}
id = len(POSTS) + 1 id = len(POSTS) + 1
author = data.author author = data.author
title = data.title title = data.title
@ -112,5 +114,3 @@ async def reply_to_post(thread_id: int, data: PostCreate):
POSTS.append(post) POSTS.append(post)
return post return post
return {'error': 'could not find parent thread'}