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,22 +95,22 @@ 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:
id = len(POSTS) + 1 return {'error': 'could not find parent thread'}
author = data.author
title = data.title
content = data.content
# Create post id = len(POSTS) + 1
post = Post( author = data.author
id=id, title = data.title
thread_id=parent.id, content = data.content
author=author,
title=title,
content=content
)
POSTS.append(post)
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