kopia lustrzana https://github.com/snarfed/bridgy-fed
web follow bug fix: error gracefully on BF user addresses
fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federatedpull/799/head
rodzic
4e5021e2b0
commit
4bcf6b463f
|
@ -106,8 +106,8 @@ class FollowCallback(indieauth.Callback):
|
|||
flash(f"{addr} isn't a native fediverse account")
|
||||
return redirect(user.user_page_path('following'))
|
||||
as2_url = webfinger.fetch_actor_url(addr)
|
||||
if not as2_url:
|
||||
flash(f"Couldn't find ActivityPub profile link for {addr}")
|
||||
if ActivityPub.owns_id(as2_url) is False:
|
||||
flash(f"{addr} isn't a native fediverse account")
|
||||
return redirect(user.user_page_path('following'))
|
||||
|
||||
# TODO(#512): follower will always be Web here, but we should generalize
|
||||
|
|
|
@ -197,7 +197,7 @@ class FollowTest(TestCase):
|
|||
source_protocol='activitypub')
|
||||
|
||||
mock_get.side_effect = (
|
||||
requests_response(''),
|
||||
requests_response(''), # indieauth https://alice.com fetch for user json
|
||||
)
|
||||
mock_post.side_effect = (
|
||||
requests_response('me=https://alice.com'),
|
||||
|
@ -229,7 +229,7 @@ class FollowTest(TestCase):
|
|||
}],
|
||||
}
|
||||
mock_get.side_effect = (
|
||||
requests_response(''),
|
||||
requests_response(''), # indieauth https://alice.com fetch for user json
|
||||
self.as2_resp(followee),
|
||||
self.as2_resp(followee),
|
||||
)
|
||||
|
@ -256,6 +256,32 @@ class FollowTest(TestCase):
|
|||
self.assertEqual(["@example.com@web.brid.gy isn't a native fediverse account"],
|
||||
get_flashed_messages())
|
||||
|
||||
def test_callback_upgraded_bridged_account_error(self, mock_get, mock_post):
|
||||
mock_post.return_value = requests_response('me=https://alice.com')
|
||||
mock_get.side_effect = [
|
||||
requests_response(''), # indieauth https://alice.com fetch for user json
|
||||
requests_response({ # webfinger
|
||||
'subject': 'acct:bob.com@bob.com',
|
||||
'aliases': ['https://bob.com/'],
|
||||
'links': [{
|
||||
'rel': 'self',
|
||||
'type': as2.CONTENT_TYPE,
|
||||
'href': 'https://web.brid.gy/bob.com',
|
||||
}],
|
||||
}),
|
||||
]
|
||||
|
||||
bob = self.make_user('bob.com', cls=Web, obj_id='https://bob.com/')
|
||||
|
||||
self.state['state'] = '@bob.com@bob.com'
|
||||
state = util.encode_oauth_state(self.state)
|
||||
resp = self.client.get(f'/follow/callback?code=my_code&state={state}')
|
||||
|
||||
self.assertEqual(302, resp.status_code)
|
||||
self.assertEqual('/web/alice.com/following', resp.headers['Location'])
|
||||
self.assertEqual(["@bob.com@bob.com isn't a native fediverse account"],
|
||||
get_flashed_messages())
|
||||
|
||||
def check(self, input, resp, expected_follow, mock_get, mock_post,
|
||||
fetched_followee=True):
|
||||
self.assertEqual(302, resp.status_code)
|
||||
|
|
Ładowanie…
Reference in New Issue