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