Skip to content

Commit 40d7b1c

Browse files
author
Danil Yarantsev
authored
Fixes a few crashes and search functionality. (#307)
* Fixes a few crashes and search functionality. * Use PostError
1 parent c468415 commit 40d7b1c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/forum.nim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,11 @@ routes:
882882
where t.id = ? and isDeleted = 0 and category = c.id;"""
883883

884884
let threadRow = getRow(db, threadsQuery, id)
885+
if threadRow[0].len == 0:
886+
let err = PostError(
887+
message: "Specified thread does not exist"
888+
)
889+
resp Http404, $(%err), "application/json"
885890
let thread = selectThread(threadRow, selectThreadAuthor(id))
886891

887892
let postsQuery =
@@ -927,9 +932,14 @@ routes:
927932

928933
get "/specific_posts.json":
929934
createTFD()
930-
var
935+
var ids: JsonNode
936+
try:
931937
ids = parseJson(@"ids")
932-
938+
except JsonParsingError:
939+
let err = PostError(
940+
message: "Invalid JSON in the `ids` parameter"
941+
)
942+
resp Http400, $(%err), "application/json"
933943
cond ids.kind == JArray
934944
let intIDs = ids.elems.map(x => x.getInt())
935945
let postsQuery = sql("""

src/fts.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SELECT
77
post_id,
88
post_content,
99
cdate,
10+
person.id,
1011
person.name AS author,
1112
person.email AS email,
1213
strftime('%s', person.lastOnline) AS lastOnline,

0 commit comments

Comments
 (0)