From 2717496bb5f2841243e5b92003a375cd681186bd Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 14 Feb 2020 09:27:05 -0700 Subject: [PATCH] Handle no replyingTo option better --- src/forum.nim | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/forum.nim b/src/forum.nim index 10d3511..9ca8abf 100644 --- a/src/forum.nim +++ b/src/forum.nim @@ -457,13 +457,21 @@ proc executeReply(c: TForumData, threadId: int, content: string, if isLocked == "1": raise newForumError("Cannot reply to a locked thread.") - let retID = insertID( - db, - crud(crCreate, "post", "author", "ip", "content", "thread", "replyingTo"), - c.userId, c.req.ip, content, $threadId, - if replyingTo.isSome(): $replyingTo.get() - else: "-1" - ) + var retID: int64 + + if replyingTo.isSome(): + retID = insertID( + db, + crud(crCreate, "post", "author", "ip", "content", "thread", "replyingTo"), + c.userId, c.req.ip, content, $threadId, $replyingTo.get() + ) + else: + retID = insertID( + db, + crud(crCreate, "post", "author", "ip", "content", "thread"), + c.userId, c.req.ip, content, $threadId + ) + discard tryExec( db, crud(crCreate, "post_fts", "id", "content"),