mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 14:49:32 +00:00
parent
206622ea38
commit
0ac9bc2678
3 changed files with 29 additions and 2 deletions
|
|
@ -58,7 +58,7 @@ proc getGraphUser*(username: string): Future[User] {.async.} =
|
|||
proc getGraphUserById*(id: string): Future[User] {.async.} =
|
||||
if id.len == 0 or id.any(c => not c.isDigit): return
|
||||
let
|
||||
url = apiReq(graphUserById, """{"rest_id": "$1"}""" % id)
|
||||
url = apiReq(graphUserById, userByRestIdVars % id)
|
||||
js = await fetchRaw(url)
|
||||
result = parseGraphUser(js)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const
|
|||
|
||||
graphUser* = "IGgvgiOx4QZndDHuD3x9TQ/UserByScreenName"
|
||||
graphUserV2* = "-ZzAG_Bckx16LMbEvHC3lg/UserResultByScreenNameQuery"
|
||||
graphUserById* = "-DAaa9jPxPswYeI2fZ9rug/UserResultByIdQuery"
|
||||
graphUserById* = "xvmVfRLmnr1alc5f2dib0Q/UserByRestId"
|
||||
graphUserTweetsV2* = "LE3eTyeqhBh2g-fX85O2eQ/UserWithProfileTweetsQueryV2"
|
||||
graphUserTweetsAndRepliesV2* = "AcYHjc_YAx-9_rKWdMsKvA/UserWithProfileTweetsAndRepliesQueryV2"
|
||||
graphUserTweets* = "PNd0vlufvrcIwrAnBYKE9g/UserTweets"
|
||||
|
|
@ -174,6 +174,11 @@ const
|
|||
"withCommunity": false
|
||||
}""".replace(" ", "").replace("\n", "")
|
||||
|
||||
userByRestIdVars* = """{
|
||||
"userId": "$1",
|
||||
"withSafetyModeUserFields": true
|
||||
}""".replace(" ", "").replace("\n", "")
|
||||
|
||||
communityTweetsVars* = """{
|
||||
"communityId": "$1", $2
|
||||
"count": 20,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ banner_image = [
|
|||
['mobile_test', 'profile_banners%2F82135242%2F1384108037%2F1500x500']
|
||||
]
|
||||
|
||||
# (user_id, expected_username) — resolving a numeric id to a profile (issue #1433)
|
||||
id_redirects = [
|
||||
['12', 'jack'],
|
||||
['44196397', 'elonmusk']
|
||||
]
|
||||
|
||||
|
||||
class ProfileTest(BaseTestCase):
|
||||
@parameterized.expand(profiles)
|
||||
|
|
@ -93,3 +99,19 @@ class ProfileTest(BaseTestCase):
|
|||
self.open_nitter(username)
|
||||
banner = self.find_element(Profile.banner + ' img')
|
||||
self.assertIn(url, banner.get_attribute('src'))
|
||||
|
||||
|
||||
class UserIdRedirectTest(BaseTestCase):
|
||||
@parameterized.expand(id_redirects)
|
||||
def test_i_user_redirect(self, user_id, username):
|
||||
"""/i/user/<id> resolves the numeric id and redirects to the profile (issue #1433)"""
|
||||
self.open_nitter(f'i/user/{user_id}')
|
||||
self.assert_true(self.get_current_url().rstrip('/').endswith(f'/{username}'))
|
||||
self.assert_exact_text(f'@{username}', Profile.username)
|
||||
|
||||
@parameterized.expand(id_redirects)
|
||||
def test_intent_user_redirect(self, user_id, username):
|
||||
"""/intent/user?user_id=<id> redirects to the profile (issue #1433)"""
|
||||
self.open_nitter(f'intent/user?user_id={user_id}')
|
||||
self.assert_true(self.get_current_url().rstrip('/').endswith(f'/{username}'))
|
||||
self.assert_exact_text(f'@{username}', Profile.username)
|
||||
|
|
|
|||
Loading…
Reference in a new issue