mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
Avoid crash if bad URL entered in 'add remote' #77
This commit is contained in:
parent
3cddfd86e8
commit
4dc0763881
1 changed files with 12 additions and 3 deletions
|
@ -38,9 +38,18 @@ def search_for_community(address: str):
|
|||
return already_exists
|
||||
|
||||
# Look up the profile address of the community using WebFinger
|
||||
# todo: try, except block around every get_request
|
||||
webfinger_data = get_request(f"https://{server}/.well-known/webfinger",
|
||||
params={'resource': f"acct:{address[1:]}"})
|
||||
try:
|
||||
webfinger_data = get_request(f"https://{server}/.well-known/webfinger",
|
||||
params={'resource': f"acct:{address[1:]}"})
|
||||
except requests.exceptions.ReadTimeout:
|
||||
time.sleep(randint(3, 10))
|
||||
try:
|
||||
webfinger_data = get_request(f"https://{server}/.well-known/webfinger",
|
||||
params={'resource': f"acct:{address[1:]}"})
|
||||
except requests.exceptions.RequestException:
|
||||
return None
|
||||
except requests.exceptions.RequestException:
|
||||
return None
|
||||
if webfinger_data.status_code == 200:
|
||||
webfinger_json = webfinger_data.json()
|
||||
for links in webfinger_json['links']:
|
||||
|
|
Loading…
Add table
Reference in a new issue