Handle posts where 'to' is a string rather than a list

merge-requests/30/head
Bob Mottram 2023-09-25 19:09:30 +01:00
parent fc0f8d1764
commit 6ee7fd3bf4
1 changed files with 18 additions and 10 deletions

View File

@ -2279,12 +2279,16 @@ def is_dm(post_json_object: {}) -> bool:
for field_name in fields: for field_name in fields:
if not post_json_object['object'].get(field_name): if not post_json_object['object'].get(field_name):
continue continue
for to_address in post_json_object['object'][field_name]: if isinstance(post_json_object['object'][field_name], list):
if to_address.endswith('#Public') or \ for to_address in post_json_object['object'][field_name]:
to_address == 'as:Public' or \ if to_address.endswith('#Public') or \
to_address == 'Public': to_address == 'as:Public' or \
return False to_address == 'Public':
if to_address.endswith('followers'): return False
if to_address.endswith('followers'):
return False
elif isinstance(post_json_object['object'][field_name], str):
if post_json_object['object'][field_name].endswith('#Public'):
return False return False
return True return True
@ -2614,10 +2618,14 @@ def is_public_post(post_json_object: {}) -> bool:
return False return False
if not post_json_object['object'].get('to'): if not post_json_object['object'].get('to'):
return False return False
for recipient in post_json_object['object']['to']: if isinstance(post_json_object['object']['to'], list):
if recipient.endswith('#Public') or \ for recipient in post_json_object['object']['to']:
recipient == 'as:Public' or \ if recipient.endswith('#Public') or \
recipient == 'Public': recipient == 'as:Public' or \
recipient == 'Public':
return True
elif isinstance(post_json_object['object']['to'], str):
if post_json_object['object']['to'].endswith('#Public'):
return True return True
return False return False