mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
Avoiding crashes from adding remotes:
If remote community is missing If remote community doesn't have a 'featured' url (e.g. KBIN) If remote community returns empty/broken outbox (e.g. KBIN returns {}) with 200 OK
This commit is contained in:
parent
6d2b722f0e
commit
e8f7551e06
3 changed files with 6 additions and 6 deletions
|
@ -564,7 +564,7 @@ def actor_json_to_model(activity_json, address, server):
|
|||
ap_followers_url=activity_json['followers'],
|
||||
ap_inbox_url=activity_json['endpoints']['sharedInbox'],
|
||||
ap_outbox_url=activity_json['outbox'],
|
||||
ap_featured_url=activity_json['featured'],
|
||||
ap_featured_url=activity_json['featured'] if 'featured' in activity_json else '',
|
||||
ap_moderators_url=mods_url,
|
||||
ap_fetched_at=utcnow(),
|
||||
ap_domain=server,
|
||||
|
|
|
@ -102,9 +102,9 @@ def add_remote():
|
|||
flash(_('Community not found.'), 'warning')
|
||||
else:
|
||||
flash(_('Community not found. If you are searching for a nsfw community it is blocked by this instance.'), 'warning')
|
||||
|
||||
if new_community.banned:
|
||||
flash(_('That community is banned from %(site)s.', site=g.site.name), 'warning')
|
||||
else:
|
||||
if new_community.banned:
|
||||
flash(_('That community is banned from %(site)s.', site=g.site.name), 'warning')
|
||||
|
||||
return render_template('community/add_remote.html',
|
||||
title=_('Add remote community'), form=form, new_community=new_community,
|
||||
|
@ -960,4 +960,4 @@ def community_moderate_banned(actor):
|
|||
else:
|
||||
abort(401)
|
||||
else:
|
||||
abort(404)
|
||||
abort(404)
|
||||
|
|
|
@ -96,7 +96,7 @@ def retrieve_mods_and_backfill(community_id: int):
|
|||
if outbox_request.status_code == 200:
|
||||
outbox_data = outbox_request.json()
|
||||
outbox_request.close()
|
||||
if outbox_data['type'] == 'OrderedCollection' and 'orderedItems' in outbox_data:
|
||||
if 'type' in outbox_data and outbox_data['type'] == 'OrderedCollection' and 'orderedItems' in outbox_data:
|
||||
activities_processed = 0
|
||||
for activity in outbox_data['orderedItems']:
|
||||
user = find_actor_or_create(activity['object']['actor'])
|
||||
|
|
Loading…
Add table
Reference in a new issue