Handle no replyingTo option better

This commit is contained in:
Joey Yakimowich-Payne 2020-02-14 09:27:05 -07:00 • committed by Andreas Rumpf
commit 2717496bb5

View file

@ -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"),