Also check 'to' and 'cc' fields within followers and unlisted posts

main
Bob Mottram 2023-09-25 19:16:48 +01:00
parent 6ee7fd3bf4
commit a470c78dda
1 changed files with 21 additions and 9 deletions

View File

@ -2641,8 +2641,12 @@ def is_followers_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('/followers'): for recipient in post_json_object['object']['to']:
if recipient.endswith('/followers'):
return True
elif isinstance(post_json_object['object']['to'], str):
if post_json_object['object']['to'].endswith('/followers'):
return True return True
return False return False
@ -2661,16 +2665,24 @@ def is_unlisted_post(post_json_object: {}) -> bool:
if not post_json_object['object'].get('cc'): if not post_json_object['object'].get('cc'):
return False return False
has_followers = False has_followers = False
for recipient in post_json_object['object']['to']: if isinstance(post_json_object['object']['to'], list):
if recipient.endswith('/followers'): for recipient in post_json_object['object']['to']:
if recipient.endswith('/followers'):
has_followers = True
break
elif isinstance(post_json_object['object']['to'], str):
if post_json_object['object']['to'].endswith('/followers'):
has_followers = True has_followers = True
break
if not has_followers: if not has_followers:
return False return False
for recipient in post_json_object['object']['cc']: if isinstance(post_json_object['object']['cc'], list):
if recipient.endswith('#Public') or \ for recipient in post_json_object['object']['cc']:
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']['cc'], str):
if post_json_object['object']['cc'].endswith('#Public'):
return True return True
return False return False