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

@ -2222,12 +2222,17 @@ def ensure_domains_match(activity: dict) -> bool:
note_actor = None
if 'actor' in activity:
note_actor = activity['actor']
elif 'attributedTo' in activity and isinstance(activity['attributedTo'], str):
note_actor = activity['attributedTo']
elif 'attributedTo' in activity and isinstance(activity['attributedTo'], list):
for a in activity['attributedTo']:
if a['type'] == 'Person':
note_actor = a['id']
elif 'attributedTo' in activity:
attributed_to = activity['attributedTo']
if isinstance(attributed_to, str):
note_actor = attributed_to
elif isinstance(attributed_to, list):
for a in attributed_to:
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: