From 07345b97cd66e8a91f406edc703705edeb9bd838 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 6 Apr 2023 10:34:39 +0100 Subject: [PATCH] Detect question rather than vote --- posts.py | 4 ++-- question.py | 8 ++++++++ webapp_timeline.py | 11 ++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/posts.py b/posts.py index d4520dcf3..0f32ba93c 100644 --- a/posts.py +++ b/posts.py @@ -105,7 +105,7 @@ from maps import geocoords_from_map_link from keys import get_person_key from markdown import markdown_to_html from followerSync import update_followers_sync_cache -from question import is_vote +from question import is_question def convert_post_content_to_html(message_json: {}) -> None: @@ -5602,7 +5602,7 @@ def download_announce(session, base_dir: str, http_prefix: str, # if poll/vote/question is not to be shown if not show_vote_posts: - if is_vote(base_dir, nickname, domain, announced_json, debug): + if is_question(announced_json): return None # set the id to the original status diff --git a/question.py b/question.py index 1cc972ca9..63e825dd0 100644 --- a/question.py +++ b/question.py @@ -192,6 +192,14 @@ def question_update_votes(base_dir: str, nickname: str, domain: str, return question_json, question_post_filename +def is_html_question(html_str: str) -> bool: + """ is the given html string a Question? + """ + if 'input type="radio" name="answer"' in html_str: + return True + return False + + def is_question(post_json_object: {}) -> bool: """ is the given post a question? """ diff --git a/webapp_timeline.py b/webapp_timeline.py index 0443a0333..0e80fb9ff 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -39,7 +39,8 @@ from webapp_column_right import get_right_column_content from webapp_headerbuttons import header_buttons_timeline from posts import is_moderator from announce import is_self_announce -from question import is_vote +from question import is_html_question +from question import is_question def _log_timeline_timing(enable_timing_log: bool, timeline_start_time, @@ -988,9 +989,9 @@ def html_timeline(default_timeline: str, continue if is_self_announce(item): continue - # if this is a vote post then should it be shown? + # is this a poll/vote/question? if not show_vote_posts: - if is_vote(base_dir, nickname, domain, item, False): + if is_question(item): continue # is the post in the memory cache of recent ones? curr_tl_str = None @@ -1054,6 +1055,10 @@ def html_timeline(default_timeline: str, if curr_tl_str: if curr_tl_str not in tl_items_str: + # is this a poll/vote/question? + if not show_vote_posts: + if is_html_question(curr_tl_str): + continue last_item_str = text_mode_separator + curr_tl_str last_post_id = \ remove_id_ending(item['id']).replace('/', '#')