fixed build errors

This commit is contained in:
PrivacyDev 2023-07-22 11:48:49 -04:00
parent b2beabf6cd
commit 813a71e4d3

View file

@ -1,5 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
import strutils, options, times, math import strutils, options, tables, times, math
import packedjson, packedjson/deserialiser import packedjson, packedjson/deserialiser
import types, parserutils, utils import types, parserutils, utils
import experimental/parser/unifiedcard import experimental/parser/unifiedcard
@ -320,94 +320,94 @@ proc parseTweetSearch*(js: JsonNode; after=""): Timeline =
if result.content.len > 0: if result.content.len > 0:
result.bottom = $(result.content[^1][0].id - 1) result.bottom = $(result.content[^1][0].id - 1)
# proc finalizeTweet(global: GlobalObjects; id: string): Tweet = proc finalizeTweet(global: GlobalObjects; id: string): Tweet =
# let intId = if id.len > 0: parseBiggestInt(id) else: 0 let intId = if id.len > 0: parseBiggestInt(id) else: 0
# result = global.tweets.getOrDefault(id, Tweet(id: intId)) result = global.tweets.getOrDefault(id, Tweet(id: intId))
# if result.quote.isSome: if result.quote.isSome:
# let quote = get(result.quote).id let quote = get(result.quote).id
# if $quote in global.tweets: if $quote in global.tweets:
# result.quote = some global.tweets[$quote] result.quote = some global.tweets[$quote]
# else: else:
# result.quote = some Tweet() result.quote = some Tweet()
# if result.retweet.isSome: if result.retweet.isSome:
# let rt = get(result.retweet).id let rt = get(result.retweet).id
# if $rt in global.tweets: if $rt in global.tweets:
# result.retweet = some finalizeTweet(global, $rt) result.retweet = some finalizeTweet(global, $rt)
# else: else:
# result.retweet = some Tweet() result.retweet = some Tweet()
# proc parsePin(js: JsonNode; global: GlobalObjects): Tweet = proc parsePin(js: JsonNode; global: GlobalObjects): Tweet =
# let pin = js{"pinEntry", "entry", "entryId"}.getStr let pin = js{"pinEntry", "entry", "entryId"}.getStr
# if pin.len == 0: return if pin.len == 0: return
# let id = pin.getId let id = pin.getId
# if id notin global.tweets: return if id notin global.tweets: return
# global.tweets[id].pinned = true global.tweets[id].pinned = true
# return finalizeTweet(global, id) return finalizeTweet(global, id)
# proc parseGlobalObjects(js: JsonNode): GlobalObjects = proc parseGlobalObjects(js: JsonNode): GlobalObjects =
# result = GlobalObjects() result = GlobalObjects()
# let let
# tweets = ? js{"globalObjects", "tweets"} tweets = ? js{"globalObjects", "tweets"}
# users = ? js{"globalObjects", "users"} users = ? js{"globalObjects", "users"}
# for k, v in users: for k, v in users:
# result.users[k] = parseUser(v, k) result.users[k] = parseUser(v, k)
# for k, v in tweets: for k, v in tweets:
# var tweet = parseTweet(v, v{"card"}) var tweet = parseTweet(v, v{"card"})
# if tweet.user.id in result.users: if tweet.user.id in result.users:
# tweet.user = result.users[tweet.user.id] tweet.user = result.users[tweet.user.id]
# result.tweets[k] = tweet result.tweets[k] = tweet
# proc parseInstructions(res: var Profile; global: GlobalObjects; js: JsonNode) = proc parseInstructions(res: var Profile; global: GlobalObjects; js: JsonNode) =
# if js.kind != JArray or js.len == 0: if js.kind != JArray or js.len == 0:
# return return
# for i in js: for i in js:
# if res.tweets.beginning and i{"pinEntry"}.notNull: if res.tweets.beginning and i{"pinEntry"}.notNull:
# with pin, parsePin(i, global): with pin, parsePin(i, global):
# res.pinned = some pin res.pinned = some pin
# with r, i{"replaceEntry", "entry"}: with r, i{"replaceEntry", "entry"}:
# if "top" in r{"entryId"}.getStr: if "top" in r{"entryId"}.getStr:
# res.tweets.top = r.getCursor res.tweets.top = r.getCursor
# elif "bottom" in r{"entryId"}.getStr: elif "bottom" in r{"entryId"}.getStr:
# res.tweets.bottom = r.getCursor res.tweets.bottom = r.getCursor
# proc parseTimeline*(js: JsonNode; after=""): Profile = proc parseTimeline*(js: JsonNode; after=""): Profile =
# result = Profile(tweets: Timeline(beginning: after.len == 0)) result = Profile(tweets: Timeline(beginning: after.len == 0))
# let global = parseGlobalObjects(? js) let global = parseGlobalObjects(? js)
# let instructions = ? js{"timeline", "instructions"} let instructions = ? js{"timeline", "instructions"}
# if instructions.len == 0: return if instructions.len == 0: return
# result.parseInstructions(global, instructions) result.parseInstructions(global, instructions)
# var entries: JsonNode var entries: JsonNode
# for i in instructions: for i in instructions:
# if "addEntries" in i: if "addEntries" in i:
# entries = i{"addEntries", "entries"} entries = i{"addEntries", "entries"}
# for e in ? entries: for e in ? entries:
# let entry = e{"entryId"}.getStr let entry = e{"entryId"}.getStr
# if "tweet" in entry or entry.startsWith("sq-I-t") or "tombstone" in entry: if "tweet" in entry or entry.startsWith("sq-I-t") or "tombstone" in entry:
# let tweet = finalizeTweet(global, e.getEntryId) let tweet = finalizeTweet(global, e.getEntryId)
# if not tweet.available: continue if not tweet.available: continue
# result.tweets.content.add tweet result.tweets.content.add tweet
# elif "cursor-top" in entry: elif "cursor-top" in entry:
# result.tweets.top = e.getCursor result.tweets.top = e.getCursor
# elif "cursor-bottom" in entry: elif "cursor-bottom" in entry:
# result.tweets.bottom = e.getCursor result.tweets.bottom = e.getCursor
# elif entry.startsWith("sq-cursor"): elif entry.startsWith("sq-cursor"):
# with cursor, e{"content", "operation", "cursor"}: with cursor, e{"content", "operation", "cursor"}:
# if cursor{"cursorType"}.getStr == "Bottom": if cursor{"cursorType"}.getStr == "Bottom":
# result.tweets.bottom = cursor{"value"}.getStr result.tweets.bottom = cursor{"value"}.getStr
# else: else:
# result.tweets.top = cursor{"value"}.getStr result.tweets.top = cursor{"value"}.getStr
proc parsePhotoRail*(js: JsonNode): PhotoRail = proc parsePhotoRail*(js: JsonNode): PhotoRail =
with error, js{"error"}: with error, js{"error"}: