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,9 +2641,13 @@ 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
if isinstance(post_json_object['object']['to'], list):
for recipient in post_json_object['object']['to']: for recipient in post_json_object['object']['to']:
if recipient.endswith('/followers'): if recipient.endswith('/followers'):
return True return True
elif isinstance(post_json_object['object']['to'], str):
if post_json_object['object']['to'].endswith('/followers'):
return True
return False return False
@ -2661,17 +2665,25 @@ 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
if isinstance(post_json_object['object']['to'], list):
for recipient in post_json_object['object']['to']: for recipient in post_json_object['object']['to']:
if recipient.endswith('/followers'): if recipient.endswith('/followers'):
has_followers = True has_followers = True
break break
elif isinstance(post_json_object['object']['to'], str):
if post_json_object['object']['to'].endswith('/followers'):
has_followers = True
if not has_followers: if not has_followers:
return False return False
if isinstance(post_json_object['object']['cc'], list):
for recipient in post_json_object['object']['cc']: for recipient in post_json_object['object']['cc']:
if recipient.endswith('#Public') or \ if recipient.endswith('#Public') or \
recipient == 'as:Public' or \ recipient == 'as:Public' or \
recipient == 'Public': recipient == 'Public':
return True return True
elif isinstance(post_json_object['object']['cc'], str):
if post_json_object['object']['cc'].endswith('#Public'):
return True
return False return False