forked from mirrors/bookwyrm
Error handling in remote user
This commit is contained in:
parent
c0bc4f3903
commit
123fe5e769
1 changed files with 12 additions and 5 deletions
|
@ -37,10 +37,14 @@ def get_or_create_remote_user(actor):
|
||||||
|
|
||||||
def fetch_user_data(actor):
|
def fetch_user_data(actor):
|
||||||
''' load the user's info from the actor url '''
|
''' load the user's info from the actor url '''
|
||||||
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
actor,
|
actor,
|
||||||
headers={'Accept': 'application/activity+json'}
|
headers={'Accept': 'application/activity+json'}
|
||||||
)
|
)
|
||||||
|
except ConnectionError:
|
||||||
|
return None
|
||||||
|
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
@ -83,7 +87,10 @@ def get_avatar(data):
|
||||||
@app.task
|
@app.task
|
||||||
def get_remote_reviews(user_id):
|
def get_remote_reviews(user_id):
|
||||||
''' ingest reviews by a new remote bookwyrm user '''
|
''' ingest reviews by a new remote bookwyrm user '''
|
||||||
|
try:
|
||||||
user = models.User.objects.get(id=user_id)
|
user = models.User.objects.get(id=user_id)
|
||||||
|
except models.User.DoesNotExist:
|
||||||
|
return
|
||||||
outbox_page = user.outbox + '?page=true'
|
outbox_page = user.outbox + '?page=true'
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
outbox_page,
|
outbox_page,
|
||||||
|
|
Loading…
Reference in a new issue