mirror of https://gitlab.com/bashrc2/epicyon
Don't show repeat icon for posts without image descriptions
parent
c25bee89cd
commit
a764fa2418
|
@ -2195,8 +2195,11 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
||||||
post_summary = ''
|
post_summary = ''
|
||||||
if post_json_object['object'].get('summary'):
|
if post_json_object['object'].get('summary'):
|
||||||
post_summary = post_json_object['object']['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 + ' ' +
|
if not disallow_announce(post_summary + ' ' +
|
||||||
post_content):
|
post_content, attachment):
|
||||||
if post_json_object.get('id'):
|
if post_json_object.get('id'):
|
||||||
post_id = post_json_object['id']
|
post_id = post_json_object['id']
|
||||||
announce_actor = \
|
announce_actor = \
|
||||||
|
|
17
utils.py
17
utils.py
|
@ -3895,7 +3895,7 @@ def is_i2p_request(calling_domain: str, referer_domain: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def disallow_announce(content: str) -> bool:
|
def disallow_announce(content: str, attachment: []) -> bool:
|
||||||
"""Are announces/boosts not allowed for the given post?
|
"""Are announces/boosts not allowed for the given post?
|
||||||
"""
|
"""
|
||||||
disallow_strings = (
|
disallow_strings = (
|
||||||
|
@ -3919,6 +3919,21 @@ def disallow_announce(content: str) -> bool:
|
||||||
for diss in disallow_strings:
|
for diss in disallow_strings:
|
||||||
if diss in content_lower:
|
if diss in content_lower:
|
||||||
return True
|
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
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2441,9 +2441,12 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
||||||
dogwhistles, translate)
|
dogwhistles, translate)
|
||||||
|
|
||||||
content_all_str = str(summary_str) + ' ' + content_str
|
content_all_str = str(summary_str) + ' ' + content_str
|
||||||
# does an emoji indicate a no boost preference?
|
# does an emoji or lack of alt text on an image indicate a
|
||||||
# if so then don't show the repeat/announce icon
|
# no boost preference? if so then don't show the repeat/announce icon
|
||||||
if disallow_announce(content_all_str):
|
attachment = []
|
||||||
|
if post_json_object['object'].get('attachment'):
|
||||||
|
attachment = post_json_object['object']['attachment']
|
||||||
|
if disallow_announce(content_all_str, attachment):
|
||||||
announce_str = ''
|
announce_str = ''
|
||||||
# does an emoji indicate a no replies preference?
|
# does an emoji indicate a no replies preference?
|
||||||
# if so then don't show the reply icon
|
# if so then don't show the reply icon
|
||||||
|
|
Loading…
Reference in New Issue