Add community notes support

Fixes #727
Fixes #1023
This commit is contained in:
Zed 2026-02-19 01:44:50 +01:00
commit 2bd664ae7d
16 changed files with 204 additions and 97 deletions

View file

@ -6,6 +6,12 @@ import experimental/parser/unifiedcard
proc parseGraphTweet(js: JsonNode): Tweet
proc parseCommunityNote(js: JsonNode): string =
let subtitle = js{"subtitle"}
result = subtitle{"text"}.getStr
with entities, subtitle{"entities"}:
result = expandBirdwatchEntities(result, entities)
proc parseUser(js: JsonNode; id=""): User =
if js.isNull: return
result = User(
@ -439,6 +445,9 @@ proc parseGraphTweet(js: JsonNode): Tweet =
for id in ids:
result.history.add parseBiggestInt(id.getStr)
with birdwatch, js{"birdwatch_pivot"}:
result.note = parseCommunityNote(birdwatch)
proc parseGraphThread(js: JsonNode): tuple[thread: Chain; self: bool] =
for t in ? js{"content", "items"}:
let entryId = t.getEntryId