1
0
Fork 0
mirror of https://github.com/zedeus/nitter.git synced 2025-04-21 08:24:05 +00:00

fix: search pai ()

This commit is contained in:
guanbinrui 2025-04-02 22:10:41 +08:00 committed by GitHub
commit 6205218f13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -3,6 +3,8 @@ import strutils, uri
import jester
import timeline, list
import ".."/routes/[router_utils, timeline]
import ".."/[query, types, api, formatters]
import ../views/[general, search]
@ -17,12 +19,11 @@ proc createJsonApiSearchRouter*(cfg: Config) =
let
prefs = cookiePrefs()
query = initQuery(params(request))
title = "Search" & (if q.len > 0: " (" & q & ")" else: "")
case query.kind
of users:
if "," in q:
redirect("/" & q)
respJsonError "Invalid search input"
var users: Result[User]
try:
users = await getGraphUserSearch(query, getCursor())
@ -30,9 +31,9 @@ proc createJsonApiSearchRouter*(cfg: Config) =
users = Result[User](beginning: true, query: query)
respJsonSuccess formatUsersAsJson(users)
of tweets:
let
tweets = await getGraphTweetSearch(query, getCursor())
respJsonSuccess formatTweetsAsJson(tweets)
let timeline = await getGraphTweetSearch(query, getCursor())
if timeline.content.len == 0: respJsonError "No results found"
respJsonSuccess formatTimelineAsJson(timeline)
else:
respJsonError "Invalid search"

View file

@ -11,7 +11,7 @@ import views/[general, about]
import routes/[
preferences, timeline, status, media, search, rss, list, debug,
unsupported, embed, resolver, router_utils]
import jsons/[health, timeline, list]
import jsons/[health, timeline, list, search]
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
const issuesUrl = "https://github.com/zedeus/nitter/issues"
@ -110,6 +110,7 @@ routes:
extend jsonapi_health, ""
extend jsonapi_list, ""
extend jsonapi_timeline, ""
extend jsonapi_search, ""
extend rss, ""
extend status, ""
extend search, ""