Fix blocking domain

merge-requests/30/head
Bob Mottram 2023-04-30 10:46:57 +01:00
parent 45f561c9ee
commit a5ac68e698
1 changed files with 8 additions and 6 deletions

View File

@ -662,7 +662,8 @@ def is_blocked(base_dir: str, nickname: str, domain: str,
if block_nickname: if block_nickname:
if block_nickname + '@*' in blocked_str: if block_nickname + '@*' in blocked_str:
return True return True
if '*@' + domain in blocked_str: if block_domain:
if '*@' + block_domain in blocked_str:
return True return True
if block_handle: if block_handle:
if blocked_str == block_handle: if blocked_str == block_handle:
@ -684,7 +685,7 @@ def is_blocked(base_dir: str, nickname: str, domain: str,
# instance allow list # instance allow list
allow_filename = base_dir + '/accounts/allowedinstances.txt' allow_filename = base_dir + '/accounts/allowedinstances.txt'
short_domain = _get_short_domain(block_domain) short_domain = _get_short_domain(block_domain)
if not short_domain: if not short_domain and block_domain:
if not text_in_file(block_domain + '\n', allow_filename): if not text_in_file(block_domain + '\n', allow_filename):
return True return True
else: else:
@ -694,7 +695,7 @@ def is_blocked(base_dir: str, nickname: str, domain: str,
# account level allow list # account level allow list
account_dir = acct_dir(base_dir, nickname, domain) account_dir = acct_dir(base_dir, nickname, domain)
allow_filename = account_dir + '/allowedinstances.txt' allow_filename = account_dir + '/allowedinstances.txt'
if os.path.isfile(allow_filename): if block_domain and os.path.isfile(allow_filename):
if not text_in_file(block_domain + '\n', allow_filename): if not text_in_file(block_domain + '\n', allow_filename):
return True return True
@ -704,6 +705,7 @@ def is_blocked(base_dir: str, nickname: str, domain: str,
if block_nickname: if block_nickname:
if text_in_file(block_nickname + '@*\n', blocking_filename): if text_in_file(block_nickname + '@*\n', blocking_filename):
return True return True
if block_domain:
if text_in_file('*@' + block_domain + '\n', blocking_filename): if text_in_file('*@' + block_domain + '\n', blocking_filename):
return True return True
if block_handle: if block_handle: