mirror of https://github.com/zedeus/nitter
notes: return 404 on errors
This commit is contained in:
parent
b304d22dd1
commit
953089a4d9
|
@ -437,6 +437,9 @@ proc parseGraphConversation*(js: JsonNode; tweetId: string): Conversation =
|
|||
result.replies.bottom = e{"content", "itemContent", "value"}.getStr
|
||||
|
||||
proc parseGraphArticle*(js: JsonNode): Article =
|
||||
if not js{"errors"}.isNull:
|
||||
return
|
||||
|
||||
let article = js{"data", "twitterArticle"}
|
||||
let meta = article{"metadata"}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import asyncdispatch, tables, asyncfutures, sequtils
|
||||
import asyncdispatch, tables, asyncfutures, options
|
||||
import jester, karax/vdom
|
||||
import ".."/[types, api]
|
||||
import ../views/[notes, tweet, general]
|
||||
|
@ -10,10 +10,10 @@ export api, notes, vdom, tweet, general, router_utils
|
|||
proc createNotesRouter*(cfg: Config) =
|
||||
router notes:
|
||||
get "/i/notes/@id":
|
||||
let
|
||||
prefs = cookiePrefs()
|
||||
path = getPath()
|
||||
article = await getGraphArticle(@"id")
|
||||
let article = await getGraphArticle(@"id")
|
||||
|
||||
if article == nil:
|
||||
resp Http404
|
||||
|
||||
var tweetFutures: seq[Future[Conversation]]
|
||||
for e in article.entities:
|
||||
|
@ -27,5 +27,8 @@ proc createNotesRouter*(cfg: Config) =
|
|||
if c != nil and c.tweet != nil:
|
||||
tweets[c.tweet.id] = c.tweet
|
||||
|
||||
let note = renderNote(article, tweets, path, prefs)
|
||||
let
|
||||
path = getPath()
|
||||
prefs = cookiePrefs()
|
||||
note = renderNote(article, tweets, path, prefs)
|
||||
resp renderMain(note, request, cfg, prefs, titleText=article.title)
|
||||
|
|
|
@ -38,6 +38,7 @@ type
|
|||
protectedUser = 22
|
||||
couldntAuth = 32
|
||||
doesntExist = 34
|
||||
invalidPermission = 37
|
||||
userNotFound = 50
|
||||
suspended = 63
|
||||
rateLimited = 88
|
||||
|
@ -120,7 +121,7 @@ type
|
|||
|
||||
PhotoRail* = seq[GalleryPhoto]
|
||||
|
||||
Article* = object
|
||||
Article* = ref object
|
||||
title*: string
|
||||
coverImage*: string
|
||||
user*: User
|
||||
|
|
Loading…
Reference in New Issue