From 1b5143f4da51625fc5f8b5f3904fd1649deb78bb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 24 Dec 2022 17:07:24 +0000 Subject: [PATCH] Alternate quote tweet formats --- utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils.py b/utils.py index 72522f5e5..55791bedd 100644 --- a/utils.py +++ b/utils.py @@ -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