tried to fix account id lookup but failed gn
This commit is contained in:
parent
4da3904b89
commit
a5c9e78f5b
@ -15,7 +15,7 @@ proc getGraphUser*(username: string): Future[User] {.async.} =
|
|||||||
proc getGraphUserById*(id: string): Future[User] {.async.} =
|
proc getGraphUserById*(id: string): Future[User] {.async.} =
|
||||||
if id.len == 0 or id.any(c => not c.isDigit): return
|
if id.len == 0 or id.any(c => not c.isDigit): return
|
||||||
let
|
let
|
||||||
variables = """{"rest_id": "$1"}""" % id
|
variables = """{"userId":"$1"}""" % id
|
||||||
params = {"variables": variables, "features": gqlFeatures}
|
params = {"variables": variables, "features": gqlFeatures}
|
||||||
js = await fetchRaw(graphUserById ? params, Api.userRestId)
|
js = await fetchRaw(graphUserById ? params, Api.userRestId)
|
||||||
result = parseGraphUser(js)
|
result = parseGraphUser(js)
|
||||||
|
|||||||
@ -15,8 +15,8 @@ const
|
|||||||
timelineApi = api / "2/timeline"
|
timelineApi = api / "2/timeline"
|
||||||
|
|
||||||
graphql = api / "graphql"
|
graphql = api / "graphql"
|
||||||
graphUser* = graphql / "u7wQyGi6oExe8_TRWGMq4Q/UserResultByScreenNameQuery"
|
graphUser* = graphql / "32pL5BWe9WKeSK1MoPvFQQ/UserByScreenName"
|
||||||
graphUserById* = graphql / "oPppcargziU1uDQHAUmH-A/UserResultByIdQuery"
|
graphUserById* = graphql / "5vdJ5sWkbSRDiiNZvwc2Yg/UserByRestId"
|
||||||
graphUserTweets* = graphql / "3JNH4e9dq1BifLxAa3UMWg/UserWithProfileTweetsQueryV2"
|
graphUserTweets* = graphql / "3JNH4e9dq1BifLxAa3UMWg/UserWithProfileTweetsQueryV2"
|
||||||
graphUserTweetsAndReplies* = graphql / "8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2"
|
graphUserTweetsAndReplies* = graphql / "8IS8MaO-2EN6GZZZb8jF0g/UserWithProfileTweetsAndRepliesQueryV2"
|
||||||
graphUserMedia* = graphql / "dexO_2tohK86JDudXXG3Yw/UserMedia"
|
graphUserMedia* = graphql / "dexO_2tohK86JDudXXG3Yw/UserMedia"
|
||||||
@ -104,7 +104,10 @@ const
|
|||||||
"profile_label_improvements_pcf_label_in_post_enabled": true,
|
"profile_label_improvements_pcf_label_in_post_enabled": true,
|
||||||
"responsive_web_grok_image_annotation_enabled": false,
|
"responsive_web_grok_image_annotation_enabled": false,
|
||||||
"responsive_web_grok_share_attachment_enabled": false,
|
"responsive_web_grok_share_attachment_enabled": false,
|
||||||
"rweb_video_screen_enabled": false
|
"rweb_video_screen_enabled": false,
|
||||||
|
"responsive_web_twitter_article_notes_tab_enabled": false,
|
||||||
|
"subscriptions_feature_can_gift_premium": false,
|
||||||
|
"hidden_profile_subscriptions_enabled": true
|
||||||
}""".replace(" ", "").replace("\n", "")
|
}""".replace(" ", "").replace("\n", "")
|
||||||
|
|
||||||
tweetVariables* = """{
|
tweetVariables* = """{
|
||||||
|
|||||||
@ -33,6 +33,10 @@ proc parseGraphUser(js: JsonNode): User =
|
|||||||
var user = js{"user_result", "result"}
|
var user = js{"user_result", "result"}
|
||||||
if user.isNull:
|
if user.isNull:
|
||||||
user = ? js{"user_results", "result"}
|
user = ? js{"user_results", "result"}
|
||||||
|
if user.isNull:
|
||||||
|
user = js{"data", "user", "result"}
|
||||||
|
if user.isNull:
|
||||||
|
user = ? js{"data", "user", "result"}
|
||||||
|
|
||||||
result = parseUser(user{"legacy"})
|
result = parseUser(user{"legacy"})
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,10 @@ proc createActivityPubRouter*(cfg: Config) =
|
|||||||
if id.len == 0:
|
if id.len == 0:
|
||||||
resp Http200, {"Content-Type": "application/json"}, """[]"""
|
resp Http200, {"Content-Type": "application/json"}, """[]"""
|
||||||
|
|
||||||
let username = await getCachedUsername(id)
|
var username = await getCachedUsername(id)
|
||||||
|
if username.len > 0:
|
||||||
|
let tmpuser = await getGraphUserById(id)
|
||||||
|
username = tmpuser.username
|
||||||
if username.len > 0:
|
if username.len > 0:
|
||||||
resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid account ID"}"""
|
resp Http404, {"Content-Type": "application/json"}, """{"error":"Invalid account ID"}"""
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user