Turning off votes applies to announced votes

main
Bob Mottram 2023-04-05 22:41:40 +01:00
parent dceffe67be
commit 8f64ecfeb3
5 changed files with 47 additions and 10 deletions

View File

@ -774,6 +774,8 @@ def _read_local_box_post(session, nickname: str, domain: str,
_say_command(say_str, say_str2, screenreader, system_language, espeak)
print('')
show_vote_posts = False
if post_json_object['type'] == 'Announce':
actor = post_json_object['actor']
name_str = get_nickname_from_actor(actor)
@ -794,7 +796,8 @@ def _read_local_box_post(session, nickname: str, domain: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blocked_cache, bold_reading)
blocked_cache, bold_reading,
show_vote_posts)
if post_json_object2:
if has_object_dict(post_json_object2):
if post_json_object2['object'].get('attributedTo') and \
@ -2585,6 +2588,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
allow_local_network_access = False
yt_replace_domain = None
twitter_replacement_domain = None
show_vote_posts = False
post_json_object2 = \
download_announce(session, base_dir,
http_prefix,
@ -2599,7 +2603,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
domain_full, person_cache,
signing_priv_key_pem,
blocked_cache,
bold_reading)
bold_reading,
show_vote_posts)
if post_json_object2:
post_json_object = post_json_object2
if post_json_object:

View File

@ -2925,6 +2925,12 @@ def _receive_announce(recent_posts_cache: {},
minimize_all_images = False
if nickname in min_images_for_accounts:
minimize_all_images = True
show_vote_posts = True
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
if os.path.isfile(show_vote_file):
show_vote_posts = False
announce_html = \
individual_post_as_html(signing_priv_key_pem, True,
recent_posts_cache, max_recent_posts,
@ -2968,7 +2974,8 @@ def _receive_announce(recent_posts_cache: {},
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blocked_cache, bold_reading)
blocked_cache, bold_reading,
show_vote_posts)
if not post_json_object:
print('WARN: unable to download announce: ' + str(message_json))
not_in_onion = True
@ -4690,6 +4697,11 @@ def _inbox_after_initial(server, inbox_start_time,
debug)
inbox_start_time = time.time()
show_vote_posts = True
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
if os.path.isfile(show_vote_file):
show_vote_posts = False
if is_image_media(session, base_dir, http_prefix,
nickname, domain, post_json_object,
yt_replace_domain,
@ -4697,7 +4709,7 @@ def _inbox_after_initial(server, inbox_start_time,
allow_local_network_access,
recent_posts_cache, debug, system_language,
domain_full, person_cache, signing_priv_key_pem,
bold_reading):
bold_reading, show_vote_posts):
# media index will be updated
update_index_list.append('tlmedia')
fitness_performance(inbox_start_time, server.fitness,

View File

@ -529,6 +529,12 @@ def post_message_to_outbox(session, translate: {},
# should this also go to the media timeline?
if box_name_index == 'inbox':
show_vote_posts = True
show_vote_file = \
acct_dir(base_dir, post_to_nickname, domain) + '/.noVotes'
if os.path.isfile(show_vote_file):
show_vote_posts = False
if is_image_media(session, base_dir, http_prefix,
post_to_nickname, domain,
message_json,
@ -539,7 +545,8 @@ def post_message_to_outbox(session, translate: {},
system_language,
domain_full, person_cache,
signing_priv_key_pem,
bold_reading):
bold_reading,
show_vote_posts):
inbox_update_index('tlmedia', base_dir,
post_to_nickname + '@' + domain,
saved_filename, debug)

View File

@ -105,6 +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
def convert_post_content_to_html(message_json: {}) -> None:
@ -3928,7 +3929,8 @@ def is_image_media(session, base_dir: str, http_prefix: str,
system_language: str,
domain_full: str, person_cache: {},
signing_priv_key_pem: str,
bold_reading: bool) -> bool:
bold_reading: bool,
show_vote_posts: bool) -> bool:
"""Returns true if the given post has attached image media
"""
if post_json_object['type'] == 'Announce':
@ -3944,7 +3946,8 @@ def is_image_media(session, base_dir: str, http_prefix: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blocked_cache, bold_reading)
blocked_cache, bold_reading,
show_vote_posts)
if post_json_announce:
post_json_object = post_json_announce
if post_json_object['type'] != 'Create':
@ -5310,7 +5313,8 @@ def download_announce(session, base_dir: str, http_prefix: str,
system_language: str,
domain_full: str, person_cache: {},
signing_priv_key_pem: str,
blocked_cache: {}, bold_reading: bool) -> {}:
blocked_cache: {}, bold_reading: bool,
show_vote_posts: bool) -> {}:
"""Download the post referenced by an announce
"""
if not post_json_object.get('object'):
@ -5596,7 +5600,11 @@ def download_announce(session, base_dir: str, http_prefix: str,
recent_posts_cache)
return None
# labelAccusatoryPost(post_json_object, translate)
# if poll/vote/question is not to be shown
if not show_vote_posts:
if is_vote(base_dir, nickname, domain, announced_json, debug):
return None
# set the id to the original status
announced_json['id'] = post_json_object['object']
announced_json['object']['id'] = post_json_object['object']

View File

@ -2086,6 +2086,10 @@ def individual_post_as_html(signing_priv_key_pem: str,
if post_json_object['type'] == 'Announce':
announce_json_object = post_json_object.copy()
blocked_cache = {}
show_vote_posts = True
show_vote_file = acct_dir(base_dir, nickname, domain) + '/.noVotes'
if os.path.isfile(show_vote_file):
show_vote_posts = False
post_json_announce = \
download_announce(session, base_dir, http_prefix,
nickname, domain, post_json_object,
@ -2097,7 +2101,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
system_language,
domain_full, person_cache,
signing_priv_key_pem,
blocked_cache, bold_reading)
blocked_cache, bold_reading,
show_vote_posts)
if not post_json_announce:
# if the announce could not be downloaded then mark it as rejected
announced_post_id = remove_id_ending(post_json_object['id'])