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.mitm_servers)
|
||||
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 acct_dir
|
||||
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 html_header_with_external_style
|
||||
from webapp_utils import html_footer
|
||||
|
@ -242,14 +242,11 @@ def html_confirm_follow(translate: {}, base_dir: str,
|
|||
'src="' + follow_profile_url + '"/></a>\n'
|
||||
follow_actor_nick = get_nickname_from_actor(follow_actor)
|
||||
if follow_actor_nick and follow_domain:
|
||||
send_block_filename = \
|
||||
acct_dir(base_dir, nickname, domain) + '/send_blocks.txt'
|
||||
if os.path.isfile(send_block_filename):
|
||||
if text_in_file('://' + follow_domain + '\n',
|
||||
send_block_filename, False):
|
||||
follow_str += \
|
||||
' <p class="followText"><b>' + \
|
||||
translate['FollowWarning'] + '</b></p>\n'
|
||||
if sending_is_blocked2(base_dir, nickname, domain,
|
||||
follow_domain, follow_actor):
|
||||
follow_str += \
|
||||
' <p class="followText"><b>' + \
|
||||
translate['FollowWarning'] + '</b></p>\n'
|
||||
follow_str += \
|
||||
' <p class="followText">' + translate['Follow'] + ' ' + \
|
||||
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_account_timezone
|
||||
from utils import get_supported_languages
|
||||
from utils import text_in_file
|
||||
from utils import get_attributed_to
|
||||
from utils import get_full_domain
|
||||
from blocking import sending_is_blocked2
|
||||
from webapp_utils import open_content_warning
|
||||
from webapp_utils import edit_check_box
|
||||
from webapp_utils import get_buy_links
|
||||
|
@ -409,30 +409,19 @@ def html_new_post(edit_post_params: {},
|
|||
translate['this post'] + '</a></p>\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):
|
||||
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
|
||||
if text_in_file(reply_actor,
|
||||
send_block_filename, False):
|
||||
new_post_text += \
|
||||
' <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'
|
||||
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 += \
|
||||
' <p class="new-post-text"><b>' + \
|
||||
translate['FollowAccountWarning'] + \
|
||||
'</b></p>\n'
|
||||
|
||||
if post_json_object:
|
||||
timezone = \
|
||||
|
|
|
@ -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 + '</p>\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 += \
|
||||
' <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 sending_is_blocked2(base_dir, nickname, domain,
|
||||
options_domain, options_actor):
|
||||
options_str += \
|
||||
' <p class="optionsText"><b>' + \
|
||||
translate['FollowAccountWarning'] + '</b></p>\n'
|
||||
|
||||
if follows_you and authorized:
|
||||
if follow_str != 'Unfollow':
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue