From 18b714616a45556af110a20041f8207d1ef9d759 Mon Sep 17 00:00:00 2001 From: freamon Date: Sun, 1 Dec 2024 01:32:46 +0000 Subject: [PATCH] Avoid AttributeError if Actor isn't a string --- app/activitypub/routes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 96e2c62f..6e1e1671 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -417,7 +417,7 @@ def shared_inbox(): log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json if store_ap_json else None, 'Missing minimum expected fields in JSON Announce object') return '', 200 - if object['actor'].startswith('https://' + current_app.config['SERVER_NAME']): + if isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']): log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, request_json if store_ap_json else None, 'Activity about local content which is already present') return '', 200 @@ -428,7 +428,7 @@ def shared_inbox(): redis_client.set(id, 1, ex=90) # Save the activity ID into redis, to avoid duplicate activities # Ignore unutilised PeerTube activity - if request_json['actor'].endswith('accounts/peertube'): + if isinstance(request_json['actor'], str) and request_json['actor'].endswith('accounts/peertube'): log_incoming_ap(id, APLOG_PT_VIEW, APLOG_IGNORED, request_json if store_ap_json else None, 'PeerTube View or CacheFile activity') return '' @@ -521,12 +521,12 @@ def replay_inbox_request(request_json): log_incoming_ap(id, APLOG_ANNOUNCE, APLOG_FAILURE, request_json, 'REPLAY: Missing minimum expected fields in JSON Announce object') return - if object['actor'].startswith('https://' + current_app.config['SERVER_NAME']): + if isinstance(object['actor'], str) and object['actor'].startswith('https://' + current_app.config['SERVER_NAME']): log_incoming_ap(id, APLOG_DUPLICATE, APLOG_IGNORED, request_json if store_ap_json else None, 'Activity about local content which is already present') return # Ignore unutilised PeerTube activity - if request_json['actor'].endswith('accounts/peertube'): + if isinstance(request_json['actor'], str) and request_json['actor'].endswith('accounts/peertube'): log_incoming_ap(id, APLOG_PT_VIEW, APLOG_IGNORED, request_json, 'REPLAY: PeerTube View or CacheFile activity') return