Detect question rather than vote

merge-requests/30/head
Bob Mottram 2023-04-06 10:34:39 +01:00
parent dde403b16e
commit 07345b97cd
3 changed files with 18 additions and 5 deletions

View File

@ -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

View File

@ -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?
"""

View File

@ -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('/', '#')