Fix parsing censored tweets
This commit is contained in:
parent
509e1dc5e8
commit
2d7e12fcb8
2 changed files with 17 additions and 5 deletions
|
@ -328,7 +328,7 @@ proc parseThread(js: JsonNode; global: GlobalObjects): tuple[thread: Chain, self
|
||||||
else:
|
else:
|
||||||
result.thread.more = -1
|
result.thread.more = -1
|
||||||
else:
|
else:
|
||||||
var tweet = finalizeTweet(global, entry.getId)
|
var tweet = finalizeTweet(global, t.getEntryId)
|
||||||
if not tweet.available:
|
if not tweet.available:
|
||||||
tweet.tombstone = getTombstone(content{"tombstone"})
|
tweet.tombstone = getTombstone(content{"tombstone"})
|
||||||
result.thread.content.add tweet
|
result.thread.content.add tweet
|
||||||
|
@ -343,8 +343,8 @@ proc parseConversation*(js: JsonNode; tweetId: string): Conversation =
|
||||||
|
|
||||||
for e in instructions[0]{"addEntries", "entries"}:
|
for e in instructions[0]{"addEntries", "entries"}:
|
||||||
let entry = e{"entryId"}.getStr
|
let entry = e{"entryId"}.getStr
|
||||||
if "tweet" in entry:
|
if "tweet" in entry or "tombstone" in entry:
|
||||||
let tweet = finalizeTweet(global, entry.getId)
|
let tweet = finalizeTweet(global, e.getEntryId)
|
||||||
if $tweet.id != tweetId:
|
if $tweet.id != tweetId:
|
||||||
result.before.content.add tweet
|
result.before.content.add tweet
|
||||||
else:
|
else:
|
||||||
|
@ -408,8 +408,8 @@ proc parseTimeline*(js: JsonNode; after=""): Timeline =
|
||||||
|
|
||||||
for e in instructions[0]{"addEntries", "entries"}:
|
for e in instructions[0]{"addEntries", "entries"}:
|
||||||
let entry = e{"entryId"}.getStr
|
let entry = e{"entryId"}.getStr
|
||||||
if "tweet" in entry or "sq-I-t" in entry:
|
if "tweet" in entry or "sq-I-t" in entry or "tombstone" in entry:
|
||||||
let tweet = finalizeTweet(global, entry.getId)
|
let tweet = finalizeTweet(global, e.getEntryId)
|
||||||
if not tweet.available: continue
|
if not tweet.available: continue
|
||||||
result.content.add tweet
|
result.content.add tweet
|
||||||
elif "cursor-top" in entry:
|
elif "cursor-top" in entry:
|
||||||
|
|
|
@ -55,6 +55,18 @@ proc getId*(js: JsonNode): int64 {.inline.} =
|
||||||
of JInt: return js.getBiggestInt()
|
of JInt: return js.getBiggestInt()
|
||||||
else: return 0
|
else: return 0
|
||||||
|
|
||||||
|
proc getEntryId*(js: JsonNode): string {.inline.} =
|
||||||
|
let entry = js{"entryId"}.getStr
|
||||||
|
if entry.len == 0: return
|
||||||
|
|
||||||
|
if "tweet" in entry:
|
||||||
|
return entry.getId
|
||||||
|
elif "tombstone" in entry:
|
||||||
|
return js{"content", "item", "content", "tombstone", "tweet", "id"}.getStr
|
||||||
|
else:
|
||||||
|
echo "unknown entry: ", entry
|
||||||
|
return
|
||||||
|
|
||||||
template getStrVal*(js: JsonNode; default=""): string =
|
template getStrVal*(js: JsonNode; default=""): string =
|
||||||
js{"string_value"}.getStr(default)
|
js{"string_value"}.getStr(default)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue