mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
3301d430b6
commit
3cd6a3289e
21
blocking.py
21
blocking.py
|
@ -2283,3 +2283,24 @@ def run_federated_blocks_daemon(base_dir: str, httpd, debug: bool) -> None:
|
||||||
httpd.max_api_blocks,
|
httpd.max_api_blocks,
|
||||||
httpd.mitm_servers)
|
httpd.mitm_servers)
|
||||||
time.sleep(seconds_per_hour * 6)
|
time.sleep(seconds_per_hour * 6)
|
||||||
|
|
||||||
|
|
||||||
|
def sending_is_blocked2(base_dir: str, nickname: str, domain: str,
|
||||||
|
to_domain: str, to_actor: str) -> bool:
|
||||||
|
"""is sending to the given actor blocked?
|
||||||
|
"""
|
||||||
|
if not to_domain:
|
||||||
|
return False
|
||||||
|
|
||||||
|
send_block_filename = \
|
||||||
|
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
||||||
|
if not os.path.isfile(send_block_filename):
|
||||||
|
return False
|
||||||
|
|
||||||
|
send_blocked = False
|
||||||
|
if text_in_file(to_actor, send_block_filename, False):
|
||||||
|
send_blocked = True
|
||||||
|
elif text_in_file('://' + to_domain + '\n', send_block_filename, False):
|
||||||
|
send_blocked = True
|
||||||
|
|
||||||
|
return send_blocked
|
||||||
|
|
|
@ -19,7 +19,7 @@ from utils import get_config_param
|
||||||
from utils import get_alt_path
|
from utils import get_alt_path
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import get_account_timezone
|
from utils import get_account_timezone
|
||||||
from utils import text_in_file
|
from blocking import sending_is_blocked2
|
||||||
from webapp_utils import set_custom_background
|
from webapp_utils import set_custom_background
|
||||||
from webapp_utils import html_header_with_external_style
|
from webapp_utils import html_header_with_external_style
|
||||||
from webapp_utils import html_footer
|
from webapp_utils import html_footer
|
||||||
|
@ -242,14 +242,11 @@ def html_confirm_follow(translate: {}, base_dir: str,
|
||||||
'src="' + follow_profile_url + '"/></a>\n'
|
'src="' + follow_profile_url + '"/></a>\n'
|
||||||
follow_actor_nick = get_nickname_from_actor(follow_actor)
|
follow_actor_nick = get_nickname_from_actor(follow_actor)
|
||||||
if follow_actor_nick and follow_domain:
|
if follow_actor_nick and follow_domain:
|
||||||
send_block_filename = \
|
if sending_is_blocked2(base_dir, nickname, domain,
|
||||||
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
follow_domain, follow_actor):
|
||||||
if os.path.isfile(send_block_filename):
|
follow_str += \
|
||||||
if text_in_file('://' + follow_domain + '\n',
|
' <p class="followText"><b>' + \
|
||||||
send_block_filename, False):
|
translate['FollowWarning'] + '</b></p>\n'
|
||||||
follow_str += \
|
|
||||||
' <p class="followText"><b>' + \
|
|
||||||
translate['FollowWarning'] + '</b></p>\n'
|
|
||||||
follow_str += \
|
follow_str += \
|
||||||
' <p class="followText">' + translate['Follow'] + ' ' + \
|
' <p class="followText">' + translate['Follow'] + ' ' + \
|
||||||
follow_actor_nick + '@' + follow_domain + ' ?</p>\n'
|
follow_actor_nick + '@' + follow_domain + ' ?</p>\n'
|
||||||
|
|
|
@ -27,9 +27,9 @@ from utils import get_currencies
|
||||||
from utils import get_category_types
|
from utils import get_category_types
|
||||||
from utils import get_account_timezone
|
from utils import get_account_timezone
|
||||||
from utils import get_supported_languages
|
from utils import get_supported_languages
|
||||||
from utils import text_in_file
|
|
||||||
from utils import get_attributed_to
|
from utils import get_attributed_to
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
|
from blocking import sending_is_blocked2
|
||||||
from webapp_utils import open_content_warning
|
from webapp_utils import open_content_warning
|
||||||
from webapp_utils import edit_check_box
|
from webapp_utils import edit_check_box
|
||||||
from webapp_utils import get_buy_links
|
from webapp_utils import get_buy_links
|
||||||
|
@ -409,30 +409,19 @@ def html_new_post(edit_post_params: {},
|
||||||
translate['this post'] + '</a></p>\n'
|
translate['this post'] + '</a></p>\n'
|
||||||
|
|
||||||
# is sending posts to this account blocked?
|
# is sending posts to this account blocked?
|
||||||
send_block_filename = \
|
reply_actor = in_reply_to
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
reply_nickname = get_nickname_from_actor(in_reply_to)
|
||||||
'/send_blocks.txt'
|
if reply_nickname:
|
||||||
if os.path.isfile(send_block_filename):
|
reply_actor = \
|
||||||
reply_actor = in_reply_to
|
in_reply_to.split('/' + reply_nickname)[0] + \
|
||||||
reply_nickname = get_nickname_from_actor(in_reply_to)
|
'/' + reply_nickname
|
||||||
if reply_nickname:
|
reply_domain, _ = get_domain_from_actor(reply_actor)
|
||||||
reply_actor = \
|
if sending_is_blocked2(base_dir, nickname, domain,
|
||||||
in_reply_to.split('/' + reply_nickname)[0] + \
|
reply_domain, reply_actor):
|
||||||
'/' + reply_nickname
|
new_post_text += \
|
||||||
if text_in_file(reply_actor,
|
' <p class="new-post-text"><b>' + \
|
||||||
send_block_filename, False):
|
translate['FollowAccountWarning'] + \
|
||||||
new_post_text += \
|
'</b></p>\n'
|
||||||
' <p class="new-post-text"><b>' + \
|
|
||||||
translate['FollowAccountWarning'] + \
|
|
||||||
'</b></p>\n'
|
|
||||||
else:
|
|
||||||
reply_domain, _ = \
|
|
||||||
get_domain_from_actor(reply_actor)
|
|
||||||
if text_in_file('://' + reply_domain + '\n',
|
|
||||||
send_block_filename, False):
|
|
||||||
new_post_text += \
|
|
||||||
' <p class="new-post-text"><b>' + \
|
|
||||||
translate['FollowWarning'] + '</b></p>\n'
|
|
||||||
|
|
||||||
if post_json_object:
|
if post_json_object:
|
||||||
timezone = \
|
timezone = \
|
||||||
|
|
|
@ -25,6 +25,7 @@ from utils import acct_dir
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import remove_domain_port
|
from utils import remove_domain_port
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
|
from blocking import sending_is_blocked2
|
||||||
from follow import is_follower_of_person
|
from follow import is_follower_of_person
|
||||||
from follow import is_following_actor
|
from follow import is_following_actor
|
||||||
from followingCalendar import receiving_calendar_events
|
from followingCalendar import receiving_calendar_events
|
||||||
|
@ -323,19 +324,11 @@ def html_person_options(default_timeline: str,
|
||||||
' @' + handle_shown + mitm_str + '</p>\n'
|
' @' + handle_shown + mitm_str + '</p>\n'
|
||||||
|
|
||||||
# is sending posts to this account blocked?
|
# is sending posts to this account blocked?
|
||||||
send_block_filename = \
|
if sending_is_blocked2(base_dir, nickname, domain,
|
||||||
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
options_domain, options_actor):
|
||||||
if os.path.isfile(send_block_filename):
|
options_str += \
|
||||||
if text_in_file(options_actor,
|
' <p class="optionsText"><b>' + \
|
||||||
send_block_filename, False):
|
translate['FollowAccountWarning'] + '</b></p>\n'
|
||||||
options_str += \
|
|
||||||
' <p class="optionsText"><b>' + \
|
|
||||||
translate['FollowAccountWarning'] + '</b></p>\n'
|
|
||||||
elif text_in_file('://' + options_domain + '\n',
|
|
||||||
send_block_filename, False):
|
|
||||||
options_str += \
|
|
||||||
' <p class="optionsText"><b>' + \
|
|
||||||
translate['FollowWarning'] + '</b></p>\n'
|
|
||||||
|
|
||||||
if follows_you and authorized:
|
if follows_you and authorized:
|
||||||
if follow_str != 'Unfollow':
|
if follow_str != 'Unfollow':
|
||||||
|
|
|
@ -35,7 +35,6 @@ from flags import is_news_post
|
||||||
from flags import is_recent_post
|
from flags import is_recent_post
|
||||||
from flags import is_chat_message
|
from flags import is_chat_message
|
||||||
from flags import is_pgp_encrypted
|
from flags import is_pgp_encrypted
|
||||||
from utils import text_in_file
|
|
||||||
from utils import text_mode_removals
|
from utils import text_mode_removals
|
||||||
from utils import remove_header_tags
|
from utils import remove_header_tags
|
||||||
from utils import get_actor_from_post_id
|
from utils import get_actor_from_post_id
|
||||||
|
@ -123,6 +122,7 @@ from speaker import update_speaker
|
||||||
from languages import auto_translate_post
|
from languages import auto_translate_post
|
||||||
from cwlists import add_cw_from_lists
|
from cwlists import add_cw_from_lists
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
|
from blocking import sending_is_blocked2
|
||||||
from reaction import html_emoji_reactions
|
from reaction import html_emoji_reactions
|
||||||
from maps import html_open_street_map
|
from maps import html_open_street_map
|
||||||
from maps import set_map_preferences_coords
|
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?
|
# Is this domain or account blocking you?
|
||||||
reply_to_domain, _ = get_domain_from_actor(reply_to_link)
|
reply_to_domain, _ = get_domain_from_actor(reply_to_link)
|
||||||
reply_to_actor = get_actor_from_post(post_json_object)
|
reply_to_actor = get_actor_from_post(post_json_object)
|
||||||
if reply_to_domain:
|
if sending_is_blocked2(base_dir, nickname, domain,
|
||||||
send_block_filename = \
|
reply_to_domain, reply_to_actor):
|
||||||
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
# You are blocked. Replies are unlikely to be received
|
||||||
if os.path.isfile(send_block_filename):
|
# so don't show the reply icon
|
||||||
reply_blocked = False
|
return ''
|
||||||
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 ''
|
|
||||||
|
|
||||||
reply_to_link += page_number_param
|
reply_to_link += page_number_param
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,7 @@ from webapp_timeline import page_number_buttons
|
||||||
from cwlists import get_cw_list_variable
|
from cwlists import get_cw_list_variable
|
||||||
from blocking import get_account_blocks
|
from blocking import get_account_blocks
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
|
from blocking import sending_is_blocked2
|
||||||
from content import remove_link_trackers_from_content
|
from content import remove_link_trackers_from_content
|
||||||
from content import bold_reading_string
|
from content import bold_reading_string
|
||||||
from roles import is_devops
|
from roles import is_devops
|
||||||
|
@ -432,10 +433,11 @@ def html_profile_after_search(authorized: bool,
|
||||||
repo_url = get_repo_url(profile_json)
|
repo_url = get_repo_url(profile_json)
|
||||||
|
|
||||||
# is sending posts to this account blocked?
|
# is sending posts to this account blocked?
|
||||||
send_block_filename = \
|
|
||||||
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
|
||||||
send_blocks_str = ''
|
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,
|
if text_in_file(person_url,
|
||||||
send_block_filename, False):
|
send_block_filename, False):
|
||||||
send_blocks_str = translate['FollowAccountWarning']
|
send_blocks_str = translate['FollowAccountWarning']
|
||||||
|
|
Loading…
Reference in New Issue