From 3cd6a3289e927866a98515d0556227f41232b363 Mon Sep 17 00:00:00 2001
From: Bob Mottram ' + \
- translate['FollowWarning'] + ' ' + \
+ translate['FollowWarning'] + ' ' + translate['Follow'] + ' ' + \
follow_actor_nick + '@' + follow_domain + ' ?
' + \ - translate['FollowAccountWarning'] + \ - '
\n' - else: - reply_domain, _ = \ - get_domain_from_actor(reply_actor) - if text_in_file('://' + reply_domain + '\n', - send_block_filename, False): - new_post_text += \ - '' + \ - translate['FollowWarning'] + '
\n' + reply_actor = in_reply_to + reply_nickname = get_nickname_from_actor(in_reply_to) + if reply_nickname: + reply_actor = \ + in_reply_to.split('/' + reply_nickname)[0] + \ + '/' + reply_nickname + reply_domain, _ = get_domain_from_actor(reply_actor) + if sending_is_blocked2(base_dir, nickname, domain, + reply_domain, reply_actor): + new_post_text += \ + '' + \ + translate['FollowAccountWarning'] + \ + '
\n' if post_json_object: timezone = \ diff --git a/webapp_person_options.py b/webapp_person_options.py index 664aab6a3..79e5de03f 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -25,6 +25,7 @@ from utils import acct_dir from utils import text_in_file from utils import remove_domain_port from blocking import is_blocked +from blocking import sending_is_blocked2 from follow import is_follower_of_person from follow import is_following_actor from followingCalendar import receiving_calendar_events @@ -323,19 +324,11 @@ def html_person_options(default_timeline: str, ' @' + handle_shown + mitm_str + '\n' # is sending posts to this account blocked? - send_block_filename = \ - acct_dir(base_dir, nickname, domain) + '/send_blocks.txt' - if os.path.isfile(send_block_filename): - if text_in_file(options_actor, - send_block_filename, False): - options_str += \ - ' \n' - elif text_in_file('://' + options_domain + '\n', - send_block_filename, False): - options_str += \ - ' \n' + if sending_is_blocked2(base_dir, nickname, domain, + options_domain, options_actor): + options_str += \ + ' \n' if follows_you and authorized: if follow_str != 'Unfollow': diff --git a/webapp_post.py b/webapp_post.py index 26a06536e..f1bee1b15 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -35,7 +35,6 @@ from flags import is_news_post from flags import is_recent_post from flags import is_chat_message from flags import is_pgp_encrypted -from utils import text_in_file from utils import text_mode_removals from utils import remove_header_tags from utils import get_actor_from_post_id @@ -123,6 +122,7 @@ from speaker import update_speaker from languages import auto_translate_post from cwlists import add_cw_from_lists from blocking import is_blocked +from blocking import sending_is_blocked2 from reaction import html_emoji_reactions from maps import html_open_street_map from maps import set_map_preferences_coords @@ -648,20 +648,11 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str, # Is this domain or account blocking you? reply_to_domain, _ = get_domain_from_actor(reply_to_link) reply_to_actor = get_actor_from_post(post_json_object) - if reply_to_domain: - send_block_filename = \ - acct_dir(base_dir, nickname, domain) + '/send_blocks.txt' - if os.path.isfile(send_block_filename): - reply_blocked = False - if text_in_file(reply_to_actor, send_block_filename, False): - reply_blocked = True - elif text_in_file('://' + reply_to_domain + '\n', - send_block_filename, False): - reply_blocked = True - if reply_blocked: - # You are blocked. Replies are unlikely to be received - # so don't show the reply icon - return '' + if sending_is_blocked2(base_dir, nickname, domain, + reply_to_domain, reply_to_actor): + # You are blocked. Replies are unlikely to be received + # so don't show the reply icon + return '' reply_to_link += page_number_param diff --git a/webapp_profile.py b/webapp_profile.py index 60a81ebe3..fe37938ae 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -114,6 +114,7 @@ from webapp_timeline import page_number_buttons from cwlists import get_cw_list_variable from blocking import get_account_blocks from blocking import is_blocked +from blocking import sending_is_blocked2 from content import remove_link_trackers_from_content from content import bold_reading_string from roles import is_devops @@ -432,10 +433,11 @@ def html_profile_after_search(authorized: bool, repo_url = get_repo_url(profile_json) # is sending posts to this account blocked? - send_block_filename = \ - acct_dir(base_dir, nickname, domain) + '/send_blocks.txt' send_blocks_str = '' - if os.path.isfile(send_block_filename): + if sending_is_blocked2(base_dir, nickname, domain, + search_domain_full, person_url): + send_block_filename = \ + acct_dir(base_dir, nickname, domain) + '/send_blocks.txt' if text_in_file(person_url, send_block_filename, False): send_blocks_str = translate['FollowAccountWarning']