Fix quoted tweet crash

This commit is contained in:
Zed 2023-04-21 04:08:25 +02:00
parent c8e8ea3ada
commit 10a912d42e
1 changed files with 7 additions and 2 deletions

View File

@ -380,14 +380,19 @@ proc parsePhotoRail*(js: JsonNode): PhotoRail =
result.add GalleryPhoto(url: url, tweetId: $t.id)
proc parseGraphTweet(js: JsonNode): Tweet =
if js.kind == JNull or js{"__typename"}.getStr == "TweetUnavailable":
if js.kind == JNull:
return Tweet(available: false)
if js{"__typename"}.getStr == "TweetTombstone":
case js{"__typename"}.getStr
of "TweetUnavailable":
return Tweet(available: false)
of "TweetTombstone":
return Tweet(
available: false,
text: js{"tombstone", "text"}.getTombstone
)
of "TweetWithVisibilityResults":
return parseGraphTweet(js{"tweet"})
var jsCard = copy(js{"card", "legacy"})
if jsCard.kind != JNull: