diff --git a/backend/forum.py b/backend/forum.py index ae272af..92dd41c 100644 --- a/backend/forum.py +++ b/backend/forum.py @@ -95,22 +95,22 @@ async def reply_to_post(thread_id: int, data: PostCreate): if thread.id == thread_id: parent = thread - if parent: - id = len(POSTS) + 1 - author = data.author - title = data.title - content = data.content + if parent is None: + return {'error': 'could not find parent thread'} - # Create post - post = Post( - id=id, - thread_id=parent.id, - author=author, - title=title, - content=content - ) - POSTS.append(post) + id = len(POSTS) + 1 + author = data.author + title = data.title + content = data.content - return post + # Create post + post = Post( + id=id, + thread_id=parent.id, + author=author, + title=title, + content=content + ) + POSTS.append(post) - return {'error': 'could not find parent thread'} + return post