
* Update deps * Replace profile timeline with GraphQL endpoint * Update GraphQL endpoint versions * Use GraphQL for profile media tab * Fix UserByRestId request * Improve routing, fixes #814 * Fix token pool JSON * Deduplicate GraphQL timeline endpoints * Update list endpoints * Use GraphQL for list tweets * Remove debug leftover * Replace old pinned tweet endpoint with GraphQL * Validate tweet ID * Minor token handling fix * Hide US-only commerce cards * Update config example * Remove http pool and gzip from token pool * Support tombstoned tweets in threads * Retry GraphQL timeout errors * Remove unnecessary 401 retry * Remove broken timeout retry * Update karax, use new bool attribute feature * Update card test * Fix odd edgecase with broken retweets * Replace search endpoints, switch Bearer token * Only parse user search if it's a list * Fix quoted tweet crash * Fix empty search query handling * Fix invalid user search errors again
34 lines
1.2 KiB
Nim
34 lines
1.2 KiB
Nim
import options
|
|
import jsony
|
|
import user, ../types/[graphuser, graphlistmembers]
|
|
from ../../types import User, Result, Query, QueryKind
|
|
|
|
proc parseGraphUser*(json: string): User =
|
|
let raw = json.fromJson(GraphUser)
|
|
|
|
if raw.data.user.result.reason.get("") == "Suspended":
|
|
return User(suspended: true)
|
|
|
|
result = toUser raw.data.user.result.legacy
|
|
result.id = raw.data.user.result.restId
|
|
result.verified = result.verified or raw.data.user.result.isBlueVerified
|
|
|
|
proc parseGraphListMembers*(json, cursor: string): Result[User] =
|
|
result = Result[User](
|
|
beginning: cursor.len == 0,
|
|
query: Query(kind: userList)
|
|
)
|
|
|
|
let raw = json.fromJson(GraphListMembers)
|
|
for instruction in raw.data.list.membersTimeline.timeline.instructions:
|
|
if instruction.kind == "TimelineAddEntries":
|
|
for entry in instruction.entries:
|
|
case entry.content.entryType
|
|
of TimelineTimelineItem:
|
|
let userResult = entry.content.itemContent.userResults.result
|
|
if userResult.restId.len > 0:
|
|
result.content.add toUser userResult.legacy
|
|
of TimelineTimelineCursor:
|
|
if entry.content.cursorType == "Bottom":
|
|
result.bottom = entry.content.value
|