Alternate quote tweet formats

main
Bob Mottram 2022-12-24 17:07:24 +00:00
parent 7383588305
commit 1b5143f4da
1 changed files with 16 additions and 0 deletions

View File

@ -4132,7 +4132,23 @@ def save_reverse_timeline(base_dir: str, reverse_sequence: []) -> []:
def is_quote_toot(post_json_object: str) -> bool:
"""Returns true if the given post is a quote toot
"""
# Pleroma implementation
if post_json_object['object'].get('quoteUri') or \
post_json_object['object'].get('quoteUrl'):
return True
# More correct ActivityPub implementation
if post_json_object['object'].get('tag'):
if isinstance(post_json_object['object']['tag'], list):
for item in post_json_object['object']['tag']:
if not isinstance(item, dict):
continue
if not item.get('type'):
continue
if not item.get('mediaType'):
continue
if item['type'] != 'Link':
continue
if 'json' not in item['mediaType']:
continue
return True
return False