Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/jsons/search.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ proc createJsonApiSearchRouter*(cfg: Config) =
get "/api/search?":
let q = @"q"
if q.len > 500:
respJsonError "Search input too long."
respJsonError("Search input too long.", "invalid_input", Http400)

let
prefs = cookiePrefs()
Expand All @@ -23,7 +23,7 @@ proc createJsonApiSearchRouter*(cfg: Config) =
case query.kind
of users:
if "," in q:
respJsonError "Invalid search input"
respJsonError("Invalid search input", "invalid_input", Http400)
var users: Result[User]
try:
users = await getGraphUserSearch(query, getCursor())
Expand All @@ -32,10 +32,10 @@ proc createJsonApiSearchRouter*(cfg: Config) =
respJsonSuccess formatUsersAsJson(users)
of tweets:
let timeline = await getGraphTweetSearch(query, getCursor())
if timeline.content.len == 0: respJsonError "No results found"
if timeline.content.len == 0: respJsonError("No results found", "no_results", Http200)
respJsonSuccess formatTimelineAsJson(timeline)
else:
respJsonError "Invalid search"
respJsonError("Invalid search", "invalid_input", Http400)

get "/api/hashtag/@hash":
redirect("/search?q=" & encodeUrl("#" & @"hash"))
2 changes: 1 addition & 1 deletion src/jsons/status.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ proc createJsonApiStatusRouter*(cfg: Config) =
let id = @"id"

if id.len > 19 or id.any(c => not c.isDigit):
respJsonError "Invalid tweet ID"
respJsonError("Invalid tweet ID", "invalid_input", Http400)

let conv = await getTweet(id, getCursor())

Expand Down
2 changes: 1 addition & 1 deletion src/jsons/timeline.nim
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ proc createJsonApiTimelineRouter*(cfg: Config) =

if query.fromUser.len != 1:
var timeline = await getGraphTweetSearch(query, after)
if timeline.content.len == 0: respJsonError "No results found"
if timeline.content.len == 0: respJsonError("No results found", "no_results", Http200)
timeline.beginning = true
respJsonSuccess formatTimelineAsJson(timeline)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/routes/router_utils.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
import strutils, sequtils, uri, tables, json
from jester import Request, cookies
from jester import Request, cookies, HttpCode, Http200

import ../views/general
import ".."/[utils, prefs, types]
Expand Down
Loading