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:
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