mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
Hopefully temporary fix for nodebb bug
This commit is contained in:
parent
2803054767
commit
c0ba8ba1e8
1 changed files with 23 additions and 6 deletions
|
@ -415,16 +415,19 @@ def shared_inbox():
|
||||||
return '', 200
|
return '', 200
|
||||||
|
|
||||||
id = request_json['id']
|
id = request_json['id']
|
||||||
|
missing_actor_in_announce_object = False # nodebb
|
||||||
if request_json['type'] == 'Announce' and isinstance(request_json['object'], dict):
|
if request_json['type'] == 'Announce' and isinstance(request_json['object'], dict):
|
||||||
object = request_json['object']
|
object = request_json['object']
|
||||||
if not 'id' in object or not 'type' in object or not 'actor' in object or not 'object' in object:
|
if not 'actor' in object:
|
||||||
|
missing_actor_in_announce_object = True
|
||||||
|
if not 'id' in object or not 'type' in object or not 'object' in object:
|
||||||
if 'type' in object and (object['type'] == 'Page' or object['type'] == 'Note'):
|
if 'type' in object and (object['type'] == 'Page' or object['type'] == 'Note'):
|
||||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_IGNORED, saved_json, 'Intended for Mastodon')
|
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_IGNORED, saved_json, 'Intended for Mastodon')
|
||||||
else:
|
else:
|
||||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, saved_json, 'Missing minimum expected fields in JSON Announce object')
|
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, saved_json, 'Missing minimum expected fields in JSON Announce object')
|
||||||
return '', 200
|
return '', 200
|
||||||
|
|
||||||
if isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']):
|
if not missing_actor_in_announce_object and isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']):
|
||||||
log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, saved_json, 'Activity about local content which is already present')
|
log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, saved_json, 'Activity about local content which is already present')
|
||||||
return '', 200
|
return '', 200
|
||||||
|
|
||||||
|
@ -499,6 +502,11 @@ def shared_inbox():
|
||||||
process_delete_request.delay(request_json, store_ap_json)
|
process_delete_request.delay(request_json, store_ap_json)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
if missing_actor_in_announce_object:
|
||||||
|
if ((request_json['object']['type'] == 'Create' or request_json['object']['type']) and
|
||||||
|
'attributedTo' in request_json['object']['object'] and isinstance(request_json['object']['object']['attributedTo'], str)):
|
||||||
|
request_json['object']['actor'] = request_json['object']['object']['attributedTo']
|
||||||
|
|
||||||
if current_app.debug:
|
if current_app.debug:
|
||||||
process_inbox_request(request_json, store_ap_json)
|
process_inbox_request(request_json, store_ap_json)
|
||||||
else:
|
else:
|
||||||
|
@ -528,17 +536,20 @@ def replay_inbox_request(request_json):
|
||||||
return
|
return
|
||||||
|
|
||||||
id = request_json['id']
|
id = request_json['id']
|
||||||
|
missing_actor_in_announce_object = False # nodebb
|
||||||
if request_json['type'] == 'Announce' and isinstance(request_json['object'], dict):
|
if request_json['type'] == 'Announce' and isinstance(request_json['object'], dict):
|
||||||
object = request_json['object']
|
object = request_json['object']
|
||||||
if not 'id' in object or not 'type' in object or not 'actor' in object or not 'object' in object:
|
if not 'actor' in object:
|
||||||
|
missing_actor_in_announce_object = True
|
||||||
|
if not 'id' in object or not 'type' in object or not 'object' in object:
|
||||||
if 'type' in object and (object['type'] == 'Page' or object['type'] == 'Note'):
|
if 'type' in object and (object['type'] == 'Page' or object['type'] == 'Note'):
|
||||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_IGNORED, request_json, 'REPLAY: Intended for Mastodon')
|
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_IGNORED, request_json, 'REPLAY: Intended for Mastodon')
|
||||||
else:
|
else:
|
||||||
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json, 'REPLAY: Missing minimum expected fields in JSON Announce object')
|
log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json, 'REPLAY: Missing minimum expected fields in JSON Announce object')
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']):
|
if not missing_actor_in_announce_object and isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']):
|
||||||
log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, saved_json, 'Activity about local content which is already present')
|
log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, request_json, 'REPLAY: Activity about local content which is already present')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Ignore unutilised PeerTube activity
|
# Ignore unutilised PeerTube activity
|
||||||
|
@ -573,6 +584,11 @@ def replay_inbox_request(request_json):
|
||||||
process_delete_request(request_json, True)
|
process_delete_request(request_json, True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if missing_actor_in_announce_object:
|
||||||
|
if ((request_json['object']['type'] == 'Create' or request_json['object']['type']) and
|
||||||
|
'attributedTo' in request_json['object']['object'] and isinstance(request_json['object']['object']['attributedTo'], str)):
|
||||||
|
request_json['object']['actor'] = request_json['object']['object']['attributedTo']
|
||||||
|
|
||||||
process_inbox_request(request_json, True)
|
process_inbox_request(request_json, True)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -799,7 +815,8 @@ def process_inbox_request(request_json, store_ap_json):
|
||||||
# inner object of Create is not a ChatMessage
|
# inner object of Create is not a ChatMessage
|
||||||
else:
|
else:
|
||||||
if (core_activity['object']['type'] == 'Note' and 'name' in core_activity['object'] and # Poll Votes
|
if (core_activity['object']['type'] == 'Note' and 'name' in core_activity['object'] and # Poll Votes
|
||||||
'inReplyTo' in core_activity['object'] and 'attributedTo' in core_activity['object']):
|
'inReplyTo' in core_activity['object'] and 'attributedTo' in core_activity['object'] and
|
||||||
|
not 'published' in core_activity['object']):
|
||||||
post_being_replied_to = Post.query.filter_by(ap_id=core_activity['object']['inReplyTo']).first()
|
post_being_replied_to = Post.query.filter_by(ap_id=core_activity['object']['inReplyTo']).first()
|
||||||
if post_being_replied_to:
|
if post_being_replied_to:
|
||||||
poll_data = Poll.query.get(post_being_replied_to.id)
|
poll_data = Poll.query.get(post_being_replied_to.id)
|
||||||
|
|
Loading…
Reference in a new issue