Fixes a few crashes and search functionality. (#307)
* Fixes a few crashes and search functionality. * Use PostError
This commit is contained in:
parent
c4684155f5
commit
40d7b1cf02
2 changed files with 13 additions and 2 deletions
|
|
@ -882,6 +882,11 @@ routes:
|
||||||
where t.id = ? and isDeleted = 0 and category = c.id;"""
|
where t.id = ? and isDeleted = 0 and category = c.id;"""
|
||||||
|
|
||||||
let threadRow = getRow(db, threadsQuery, id)
|
let threadRow = getRow(db, threadsQuery, id)
|
||||||
|
if threadRow[0].len == 0:
|
||||||
|
let err = PostError(
|
||||||
|
message: "Specified thread does not exist"
|
||||||
|
)
|
||||||
|
resp Http404, $(%err), "application/json"
|
||||||
let thread = selectThread(threadRow, selectThreadAuthor(id))
|
let thread = selectThread(threadRow, selectThreadAuthor(id))
|
||||||
|
|
||||||
let postsQuery =
|
let postsQuery =
|
||||||
|
|
@ -927,9 +932,14 @@ routes:
|
||||||
|
|
||||||
get "/specific_posts.json":
|
get "/specific_posts.json":
|
||||||
createTFD()
|
createTFD()
|
||||||
var
|
var ids: JsonNode
|
||||||
|
try:
|
||||||
ids = parseJson(@"ids")
|
ids = parseJson(@"ids")
|
||||||
|
except JsonParsingError:
|
||||||
|
let err = PostError(
|
||||||
|
message: "Invalid JSON in the `ids` parameter"
|
||||||
|
)
|
||||||
|
resp Http400, $(%err), "application/json"
|
||||||
cond ids.kind == JArray
|
cond ids.kind == JArray
|
||||||
let intIDs = ids.elems.map(x => x.getInt())
|
let intIDs = ids.elems.map(x => x.getInt())
|
||||||
let postsQuery = sql("""
|
let postsQuery = sql("""
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ SELECT
|
||||||
post_id,
|
post_id,
|
||||||
post_content,
|
post_content,
|
||||||
cdate,
|
cdate,
|
||||||
|
person.id,
|
||||||
person.name AS author,
|
person.name AS author,
|
||||||
person.email AS email,
|
person.email AS email,
|
||||||
strftime('%s', person.lastOnline) AS lastOnline,
|
strftime('%s', person.lastOnline) AS lastOnline,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue