diff --git a/daemon_get_buttons_announce.py b/daemon_get_buttons_announce.py index a0d2903e1..045ac28f5 100644 --- a/daemon_get_buttons_announce.py +++ b/daemon_get_buttons_announce.py @@ -24,6 +24,7 @@ from httpcodes import http_404 from announce import create_announce from posts import save_post_to_box from daemon_utils import post_to_outbox +from daemon_utils import detect_mitm from fitnessFunctions import fitness_performance from follow import follower_approval_active from webapp_post import individual_post_as_html @@ -212,10 +213,12 @@ def announce_button(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(announce_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + announce_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True diff --git a/daemon_get_buttons_bookmark.py b/daemon_get_buttons_bookmark.py index b853ba166..20a80ac83 100644 --- a/daemon_get_buttons_bookmark.py +++ b/daemon_get_buttons_bookmark.py @@ -25,6 +25,7 @@ from bookmarks import undo_bookmark_post from follow import follower_approval_active from webapp_post import individual_post_as_html from fitnessFunctions import fitness_performance +from daemon_utils import detect_mitm def bookmark_button(self, calling_domain: str, path: str, @@ -167,10 +168,12 @@ def bookmark_button(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(bookmark_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + bookmark_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True @@ -372,10 +375,12 @@ def bookmark_button_undo(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(bookmark_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + bookmark_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True diff --git a/daemon_get_buttons_like.py b/daemon_get_buttons_like.py index 8bee50e0d..72d4467bc 100644 --- a/daemon_get_buttons_like.py +++ b/daemon_get_buttons_like.py @@ -27,6 +27,7 @@ from posts import get_original_post_from_announce_url from fitnessFunctions import fitness_performance from like import update_likes_collection from webapp_post import individual_post_as_html +from daemon_utils import detect_mitm def like_button(self, calling_domain: str, path: str, @@ -214,10 +215,12 @@ def like_button(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(liked_post_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + liked_post_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True @@ -463,10 +466,12 @@ def like_button_undo(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(liked_post_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + liked_post_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True diff --git a/daemon_get_buttons_mute.py b/daemon_get_buttons_mute.py index b2b1d490f..5a4cece60 100644 --- a/daemon_get_buttons_mute.py +++ b/daemon_get_buttons_mute.py @@ -22,6 +22,7 @@ from blocking import mute_post from follow import follower_approval_active from webapp_post import individual_post_as_html from fitnessFunctions import fitness_performance +from daemon_utils import detect_mitm def mute_button(self, calling_domain: str, path: str, @@ -129,10 +130,12 @@ def mute_button(self, calling_domain: str, path: str, timezone = None if account_timezone.get(nickname): timezone = account_timezone.get(nickname) - mitm = False - if os.path.isfile(mute_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + mute_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True @@ -301,10 +304,12 @@ def mute_button_undo(self, calling_domain: str, path: str, timezone = None if account_timezone.get(nickname): timezone = account_timezone.get(nickname) - mitm = False - if os.path.isfile(mute_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + mute_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(nickname): bold_reading = True diff --git a/daemon_get_buttons_reaction.py b/daemon_get_buttons_reaction.py index 9af7b6a02..5f280ed87 100644 --- a/daemon_get_buttons_reaction.py +++ b/daemon_get_buttons_reaction.py @@ -24,6 +24,7 @@ from session import establish_session from httpcodes import http_404 from posts import get_original_post_from_announce_url from daemon_utils import post_to_outbox +from daemon_utils import detect_mitm from fitnessFunctions import fitness_performance from reaction import update_reaction_collection from follow import follower_approval_active @@ -243,10 +244,12 @@ def reaction_button(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(reaction_post_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + reaction_post_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True @@ -514,10 +517,12 @@ def reaction_button_undo(self, calling_domain: str, path: str, timezone = None if account_timezone.get(self.post_to_nickname): timezone = account_timezone.get(self.post_to_nickname) - mitm = False - if os.path.isfile(reaction_post_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + reaction_post_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(self.post_to_nickname): bold_reading = True diff --git a/daemon_get_post.py b/daemon_get_post.py index ffe899d6e..d44eee7cd 100644 --- a/daemon_get_post.py +++ b/daemon_get_post.py @@ -47,6 +47,7 @@ from fitnessFunctions import fitness_performance from securemode import secure_mode from context import get_individual_post_context from conversation import convthread_id_to_conversation_tag +from daemon_utils import detect_mitm def _show_post_from_file(self, post_filename: str, liked_by: str, @@ -121,10 +122,12 @@ def _show_post_from_file(self, post_filename: str, liked_by: str, if account_timezone.get(nickname): timezone = account_timezone.get(nickname) - mitm = False - if os.path.isfile(post_filename.replace('.json', '') + - '.mitm'): - mitm = True + mitm = detect_mitm(self) + if not mitm: + mitm_filename = \ + post_filename.replace('.json', '') + '.mitm' + if os.path.isfile(mitm_filename): + mitm = True bold_reading = False if bold_reading_nicknames.get(nickname): diff --git a/daemon_utils.py b/daemon_utils.py index 09dfa8e87..142d3f2c3 100644 --- a/daemon_utils.py +++ b/daemon_utils.py @@ -207,7 +207,7 @@ def post_to_outbox_thread(self, message_json: {}, return True -def _detect_mitm(self) -> bool: +def detect_mitm(self) -> bool: """Detect if a request contains a MiTM """ mitm_domains = ['cloudflare'] @@ -524,7 +524,7 @@ def update_inbox_queue(self, nickname: str, message_json: {}, self.server.blocked_cache_last_updated, self.server.blocked_cache_update_secs) - mitm = _detect_mitm(self) + mitm = detect_mitm(self) if debug: print('INBOX: saving post to queue')