From f10fb60577d2ec61c9a1e0696040d86f812d8d73 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:24:57 +1300 Subject: [PATCH] sometimes attributedTo is a list of strings or Person dicts --- app/activitypub/util.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 3ffaee31..45325161 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -2557,10 +2557,22 @@ def verify_object_from_source(request_json): if not 'id' in object or not 'type' in object or not 'attributedTo' in object: return None + actor_domain = '' if isinstance(object['attributedTo'], str): actor_domain = urlparse(object['attributedTo']).netloc elif isinstance(object['attributedTo'], dict) and 'id' in object['attributedTo']: actor_domain = urlparse(object['attributedTo']['id']).netloc + elif isinstance(object['attributedTo'], list): + for a in object['attributedTo']: + if isinstance(a, str): + actor_domain = urlparse(a).netloc + break + elif isinstance(a, dict) and a.get('type') == 'Person': + actor = a.get('id') + if isinstance(actor, str): + parsed_url = urlparse(actor) + actor_domain = parsed_url.netloc + break else: return None