refactor: move unknown parent thread check
This commit is contained in:
parent
002fc63c90
commit
4228107b54
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user