From 05197552cbcf6f3502a583e06365c83dd710f977 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 16:06:24 +0100 Subject: [PATCH 1/6] Remove any fraction from published time when checking recency --- inbox.py | 2 ++ utils.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/inbox.py b/inbox.py index ef6498d68..d66615953 100644 --- a/inbox.py +++ b/inbox.py @@ -2505,6 +2505,8 @@ def _valid_post_content(base_dir: str, nickname: str, domain: str, if 'T' not in published: return False if 'Z' not in published: + print('REJECT inbox post does not use Zulu time format. ' + + published) return False if '.' in published: # converts 2022-03-30T17:37:58.734Z into 2022-03-30T17:37:58Z diff --git a/utils.py b/utils.py index 9a80fef27..967b4c56c 100644 --- a/utils.py +++ b/utils.py @@ -2753,6 +2753,8 @@ def is_recent_post(post_json_object: {}, max_days: int) -> bool: recently = days_since_epoch - max_days published_date_str = post_json_object['object']['published'] + if '.' in published_date_str: + published_date_str = published_date_str.split('.')[0] + 'Z' try: published_date = \ datetime.datetime.strptime(published_date_str, From 365c0626a1e4a93b6d8a7e2b522f1e1c76a5844d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 17:50:40 +0100 Subject: [PATCH 2/6] Extra no reply preferences --- webapp_post.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webapp_post.py b/webapp_post.py index 9175930d4..47a409102 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -2025,7 +2025,10 @@ def individual_post_as_html(signing_priv_key_pem: str, ':noboosts:' in content_str or \ ':no_boost:' in content_str or \ ':no_boosts:' in content_str or \ - ':boosts_no:' in content_str: + ':boosts_no:' in content_str or \ + 'dont_repeat' in content_str or \ + 'dont_announce' in content_str or \ + 'dont_boost' in content_str: announce_str = '' # does an emoji indicate a no replies preference? # if so then don't show the reply icon @@ -2034,7 +2037,8 @@ def individual_post_as_html(signing_priv_key_pem: str, ':noreplies:' in content_str or \ ':no_reply:' in content_str or \ ':no_replies:' in content_str or \ - ':replies_no:' in content_str: + ':replies_no:' in content_str or \ + 'dont_at_me' in content_str: reply_str = '' new_footer_str = \ From 3a1dcc22cfbe3806aad8bde731f0426ef7fb67fa Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 18:15:48 +0100 Subject: [PATCH 3/6] Use reply and announce inhibitors in desktop client --- desktop_client.py | 94 +++++++++++++++++++++++++++-------------------- utils.py | 38 +++++++++++++++++++ webapp_post.py | 20 ++-------- 3 files changed, 96 insertions(+), 56 deletions(-) diff --git a/desktop_client.py b/desktop_client.py index 49f094fb2..5330a2f5f 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -16,6 +16,8 @@ import webbrowser import urllib.parse from pathlib import Path from random import randint +from utils import disallow_announce +from utils import disallow_reply from utils import get_base_content_from_post from utils import has_object_dict from utils import get_full_domain @@ -1757,27 +1759,34 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, print('') elif command_str in ('reply', 'r'): if post_json_object: - if post_json_object.get('id'): - post_id = post_json_object['id'] - subject = None - if post_json_object['object'].get('summary'): - subject = post_json_object['object']['summary'] - conversation_id = None - if post_json_object['object'].get('conversation'): - conversation_id = \ - post_json_object['object']['conversation'] - session_reply = create_session(proxy_type) - _desktop_reply_to_post(session_reply, post_id, - base_dir, nickname, password, - domain, port, http_prefix, - cached_webfingers, person_cache, - debug, subject, - screenreader, system_language, - languages_understood, - espeak, conversation_id, - low_bandwidth, - content_license_url, - signing_priv_key_pem) + post_content = '' + if post_json_object['object'].get('content'): + post_content = post_json_object['object']['content'] + if not disallow_reply(post_content): + if post_json_object.get('id'): + post_id = post_json_object['id'] + subject = None + if post_json_object['object'].get('summary'): + subject = post_json_object['object']['summary'] + conversation_id = None + if post_json_object['object'].get('conversation'): + conversation_id = \ + post_json_object['object']['conversation'] + session_reply = create_session(proxy_type) + _desktop_reply_to_post(session_reply, post_id, + base_dir, nickname, + password, + domain, port, http_prefix, + cached_webfingers, + person_cache, + debug, subject, + screenreader, + system_language, + languages_understood, + espeak, conversation_id, + low_bandwidth, + content_license_url, + signing_priv_key_pem) refresh_timeline = True print('') elif (command_str == 'post' or command_str == 'p' or @@ -2130,25 +2139,30 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, post_json_object = \ _desktop_get_box_post_object(box_json, curr_index) if post_json_object: - if post_json_object.get('id'): - post_id = post_json_object['id'] - announce_actor = \ - post_json_object['object']['attributedTo'] - say_str = 'Announcing post by ' + \ - get_nickname_from_actor(announce_actor) - _say_command(say_str, say_str, - screenreader, - system_language, espeak) - session_announce = create_session(proxy_type) - send_announce_via_server(base_dir, session_announce, - nickname, password, - domain, port, - http_prefix, post_id, - cached_webfingers, - person_cache, - True, __version__, - signing_priv_key_pem) - refresh_timeline = True + post_content = '' + if post_json_object['object'].get('content'): + post_content = post_json_object['object']['content'] + if not disallow_announce(post_content): + if post_json_object.get('id'): + post_id = post_json_object['id'] + announce_actor = \ + post_json_object['object']['attributedTo'] + say_str = 'Announcing post by ' + \ + get_nickname_from_actor(announce_actor) + _say_command(say_str, say_str, + screenreader, + system_language, espeak) + session_announce = create_session(proxy_type) + send_announce_via_server(base_dir, + session_announce, + nickname, password, + domain, port, + http_prefix, post_id, + cached_webfingers, + person_cache, + True, __version__, + signing_priv_key_pem) + refresh_timeline = True print('') elif (command_str.startswith('unannounce') or command_str.startswith('undo announce') or diff --git a/utils.py b/utils.py index 967b4c56c..1b647e116 100644 --- a/utils.py +++ b/utils.py @@ -3614,3 +3614,41 @@ def is_i2p_request(calling_domain: str, referer_domain: str, if referer_domain.endswith('.i2p'): return True return False + + +def disallow_announce(content: str) -> bool: + """Are announces/boosts not allowed for the given post? + """ + disallow_strings = ( + ':boost_no:', + ':noboost:', + ':noboosts:', + ':no_boost:', + ':no_boosts:', + ':boosts_no:', + 'dont_repeat', + 'dont_announce', + 'dont_boost' + ) + for diss in disallow_strings: + if diss in content: + return True + return False + + +def disallow_reply(content: str) -> bool: + """Are replies not allowed for the given post? + """ + disallow_strings = ( + ':reply_no:', + ':noreply:', + ':noreplies:', + ':no_reply:', + ':no_replies:', + ':replies_no:', + 'dont_at_me' + ) + for diss in disallow_strings: + if diss in content: + return True + return False diff --git a/webapp_post.py b/webapp_post.py index 47a409102..a766e786c 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -25,6 +25,8 @@ from posts import post_is_muted from posts import get_person_box from posts import download_announce from posts import populate_replies_json +from utils import disallow_announce +from utils import disallow_reply from utils import convert_published_to_local_timezone from utils import remove_hash_from_post_id from utils import remove_html @@ -2020,25 +2022,11 @@ def individual_post_as_html(signing_priv_key_pem: str, if content_str: # does an emoji indicate a no boost preference? # if so then don't show the repeat/announce icon - if ':boost_no:' in content_str or \ - ':noboost:' in content_str or \ - ':noboosts:' in content_str or \ - ':no_boost:' in content_str or \ - ':no_boosts:' in content_str or \ - ':boosts_no:' in content_str or \ - 'dont_repeat' in content_str or \ - 'dont_announce' in content_str or \ - 'dont_boost' in content_str: + if disallow_announce(content_str): announce_str = '' # does an emoji indicate a no replies preference? # if so then don't show the reply icon - if ':reply_no:' in content_str or \ - ':noreply:' in content_str or \ - ':noreplies:' in content_str or \ - ':no_reply:' in content_str or \ - ':no_replies:' in content_str or \ - ':replies_no:' in content_str or \ - 'dont_at_me' in content_str: + if disallow_reply(content_str): reply_str = '' new_footer_str = \ From 7cd5fabffa915b7a790367d7d7971acc0ce8dc12 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 18:24:19 +0100 Subject: [PATCH 4/6] Read or show --- desktop_client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/desktop_client.py b/desktop_client.py index 5330a2f5f..01a912b11 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -1664,11 +1664,17 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, screenreader, system_language, espeak, page_number, new_replies_exist, new_dms_exist) - elif command_str.startswith('read ') or command_str == 'read': - if command_str == 'read': + elif (command_str.startswith('read ') or + command_str == 'read' or + command_str == 'show'): + if command_str == 'read' or \ + command_str == 'show': post_index_str = '1' else: - post_index_str = command_str.split('read ')[1] + if 'read ' in command_str: + post_index_str = command_str.split('read ')[1] + else: + post_index_str = command_str.split('show ')[1] if box_json and post_index_str.isdigit(): _desktop_clear_screen() _desktop_show_banner() From 3837f015b8557abd38f3f276ea052d69b47189d5 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 18:26:16 +0100 Subject: [PATCH 5/6] Read or show --- desktop_client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/desktop_client.py b/desktop_client.py index 01a912b11..e4a44f8d8 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -119,6 +119,8 @@ def _desktop_help() -> None: 'Previous page in the timeline') print(indent + 'read [post number] ' + 'Read a post from a timeline') + print(indent + 'show [post number] ' + + 'Read a post from a timeline') print(indent + 'open [post number] ' + 'Open web links within a timeline post') print(indent + 'profile [post number or handle] ' + @@ -1665,6 +1667,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, page_number, new_replies_exist, new_dms_exist) elif (command_str.startswith('read ') or + command_str.startswith('show ') or command_str == 'read' or command_str == 'show'): if command_str == 'read' or \ From 75e134bae7787b05e32aa0af0094a483548b4875 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 8 May 2022 18:34:14 +0100 Subject: [PATCH 6/6] Abbreviated speak command --- desktop_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop_client.py b/desktop_client.py index e4a44f8d8..805bc2c4a 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -2443,8 +2443,10 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, notification_sounds = False elif command_str in ('speak', 'screen reader on', + 'speak on', 'speaker on', 'talker on', + 'talk on', 'reader on'): if original_screen_reader: screenreader = original_screen_reader