sometimes attributedTo is a list of strings

This commit is contained in:
rimu 2025-01-08 12:19:10 +13:00
parent 3a526e0ca7
commit cf14b186c1

View file

@ -2217,18 +2217,23 @@ def ensure_domains_match(activity: dict) -> bool:
if 'id' in activity: if 'id' in activity:
note_id = activity['id'] note_id = activity['id']
else: else:
note_id = None note_id = None
note_actor = None note_actor = None
if 'actor' in activity: if 'actor' in activity:
note_actor = activity['actor'] note_actor = activity['actor']
elif 'attributedTo' in activity and isinstance(activity['attributedTo'], str): elif 'attributedTo' in activity:
note_actor = activity['attributedTo'] attributed_to = activity['attributedTo']
elif 'attributedTo' in activity and isinstance(activity['attributedTo'], list): if isinstance(attributed_to, str):
for a in activity['attributedTo']: note_actor = attributed_to
if a['type'] == 'Person': elif isinstance(attributed_to, list):
note_actor = a['id'] for a in attributed_to:
break if isinstance(a, dict) and a.get('type') == 'Person':
note_actor = a.get('id')
break
elif isinstance(a, str):
note_actor = a
break
if note_id and note_actor: if note_id and note_actor:
parsed_url = urlparse(note_id) parsed_url = urlparse(note_id)