diff --git a/desktop_client.py b/desktop_client.py index 9a21a3d6b..19d3234ba 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -2195,8 +2195,11 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, post_summary = '' if post_json_object['object'].get('summary'): post_summary = post_json_object['object']['summary'] + attachment = [] + if post_json_object['object'].get('attachment'): + attachment = post_json_object['object']['attachment'] if not disallow_announce(post_summary + ' ' + - post_content): + post_content, attachment): if post_json_object.get('id'): post_id = post_json_object['id'] announce_actor = \ diff --git a/utils.py b/utils.py index 656358261..6e8a8211e 100644 --- a/utils.py +++ b/utils.py @@ -3895,7 +3895,7 @@ def is_i2p_request(calling_domain: str, referer_domain: str, return False -def disallow_announce(content: str) -> bool: +def disallow_announce(content: str, attachment: []) -> bool: """Are announces/boosts not allowed for the given post? """ disallow_strings = ( @@ -3919,6 +3919,21 @@ def disallow_announce(content: str) -> bool: for diss in disallow_strings: if diss in content_lower: return True + + # check for attached images without descriptions + if isinstance(attachment, list): + for item in attachment: + if not isinstance(item. dict): + continue + if not item.get('mediaType'): + continue + if not item.get('url'): + continue + if not item['mediaType'].startswith('image/'): + continue + if not item.get('name'): + # no image description + return True return False diff --git a/webapp_post.py b/webapp_post.py index 6b0b975ae..ab507c401 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -2441,9 +2441,12 @@ def individual_post_as_html(signing_priv_key_pem: str, dogwhistles, translate) content_all_str = str(summary_str) + ' ' + content_str - # does an emoji indicate a no boost preference? - # if so then don't show the repeat/announce icon - if disallow_announce(content_all_str): + # does an emoji or lack of alt text on an image indicate a + # no boost preference? if so then don't show the repeat/announce icon + attachment = [] + if post_json_object['object'].get('attachment'): + attachment = post_json_object['object']['attachment'] + if disallow_announce(content_all_str, attachment): announce_str = '' # does an emoji indicate a no replies preference? # if so then don't show the reply icon