From 448b0e3120c442aae3aac6f4047d07b388534901 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 14 Jun 2022 11:51:40 +0100 Subject: [PATCH] Tidying --- inbox.py | 2 +- languages.py | 2 +- like.py | 3 +-- outbox.py | 3 +-- posts.py | 2 +- question.py | 16 ++++++++-------- schedule.py | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/inbox.py b/inbox.py index 89eefaa62..3ea239f27 100644 --- a/inbox.py +++ b/inbox.py @@ -2686,7 +2686,7 @@ def _valid_post_content(base_dir: str, nickname: str, domain: str, message_json['object']['tag']) return False # check that the post is in a language suitable for this account - if not understood_post_language(base_dir, nickname, domain, + if not understood_post_language(base_dir, nickname, message_json, system_language, http_prefix, domain_full, person_cache): diff --git a/languages.py b/languages.py index 7b4836692..4563cf8ab 100644 --- a/languages.py +++ b/languages.py @@ -99,7 +99,7 @@ def set_actor_languages(actor_json: {}, languages_str: str) -> None: actor_json['attachment'].append(new_languages) -def understood_post_language(base_dir: str, nickname: str, domain: str, +def understood_post_language(base_dir: str, nickname: str, message_json: {}, system_language: str, http_prefix: str, domain_full: str, person_cache: {}) -> bool: diff --git a/like.py b/like.py index 75814e882..ee19e461d 100644 --- a/like.py +++ b/like.py @@ -385,8 +385,7 @@ def outbox_like(recent_posts_cache: {}, def outbox_undo_like(recent_posts_cache: {}, - base_dir: str, http_prefix: str, - nickname: str, domain: str, port: int, + base_dir: str, nickname: str, domain: str, message_json: {}, debug: bool) -> None: """ When an undo like request is received by the outbox from c2s """ diff --git a/outbox.py b/outbox.py index bcd0a072f..878897a0c 100644 --- a/outbox.py +++ b/outbox.py @@ -580,8 +580,7 @@ def post_message_to_outbox(session, translate: {}, if debug: print('DEBUG: handle any undo like requests') outbox_undo_like(recent_posts_cache, - base_dir, http_prefix, - post_to_nickname, domain, port, + base_dir, post_to_nickname, domain, message_json, debug) if debug: diff --git a/posts.py b/posts.py index fb796e159..86ad51444 100644 --- a/posts.py +++ b/posts.py @@ -4998,7 +4998,7 @@ def download_announce(session, base_dir: str, http_prefix: str, base_dir, nickname, domain, post_id, recent_posts_cache) return None - if not understood_post_language(base_dir, nickname, domain, + if not understood_post_language(base_dir, nickname, announced_json, system_language, http_prefix, domain_full, person_cache): diff --git a/question.py b/question.py index 2e36efe36..04b7561c4 100644 --- a/question.py +++ b/question.py @@ -136,20 +136,20 @@ def question_update_votes(base_dir: str, nickname: str, domain: str, return question_json, question_post_filename -def is_question(postObjectJson: {}) -> bool: +def is_question(post_object_json: {}) -> bool: """ is the given post a question? """ - if postObjectJson['type'] != 'Create' and \ - postObjectJson['type'] != 'Update': + if post_object_json['type'] != 'Create' and \ + post_object_json['type'] != 'Update': return False - if not has_object_dict(postObjectJson): + if not has_object_dict(post_object_json): return False - if not postObjectJson['object'].get('type'): + if not post_object_json['object'].get('type'): return False - if postObjectJson['object']['type'] != 'Question': + if post_object_json['object']['type'] != 'Question': return False - if not postObjectJson['object'].get('oneOf'): + if not post_object_json['object'].get('oneOf'): return False - if not isinstance(postObjectJson['object']['oneOf'], list): + if not isinstance(post_object_json['object']['oneOf'], list): return False return True diff --git a/schedule.py b/schedule.py index 810474b08..d8fa45576 100644 --- a/schedule.py +++ b/schedule.py @@ -193,7 +193,7 @@ def run_post_schedule(base_dir: str, httpd, max_scheduled_posts: int): def run_post_schedule_watchdog(project_version: str, httpd) -> None: """This tries to keep the scheduled post thread running even if it dies """ - print('THREAD: Starting scheduled post watchdog') + print('THREAD: Starting scheduled post watchdog ' + project_version) post_schedule_original = \ httpd.thrPostSchedule.clone(run_post_schedule) httpd.thrPostSchedule.start()