Not case sensitive

main
Bob Mottram 2022-12-30 21:07:19 +00:00
parent cb24ea272d
commit 863bf90e25
3 changed files with 35 additions and 8 deletions

View File

@ -693,22 +693,22 @@ def allowed_announce(base_dir: str, nickname: str, domain: str,
base_dir + '/accounts/noannounce.txt'
if os.path.isfile(global_announce_blocks_filename):
if text_in_file('*@' + block_domain,
global_announce_blocks_filename):
global_announce_blocks_filename, False):
return False
if block_handle:
block_str = block_handle + '\n'
if text_in_file(block_str,
global_announce_blocks_filename):
global_announce_blocks_filename, False):
return False
# non-cached account level announce blocks
account_dir = acct_dir(base_dir, nickname, domain)
blocking_filename = account_dir + '/noannounce.txt'
if os.path.isfile(blocking_filename):
if text_in_file('*@' + block_domain + '\n', blocking_filename):
if text_in_file('*@' + block_domain + '\n', blocking_filename, False):
return False
if block_handle:
if text_in_file(block_handle + '\n', blocking_filename):
if text_in_file(block_handle + '\n', blocking_filename, False):
return False
return True
@ -721,13 +721,15 @@ def allowed_announce_add(base_dir: str, nickname: str, domain: str,
account_dir = acct_dir(base_dir, nickname, domain)
blocking_filename = account_dir + '/noannounce.txt'
handle = following_nickname + '@' + following_domain
if text_in_file(handle + '\n', blocking_filename):
if text_in_file(handle + '\n', blocking_filename, False):
file_text = ''
try:
with open(blocking_filename, 'r',
encoding='utf-8') as fp_noannounce:
file_text = fp_noannounce.read()
file_text = file_text.replace(handle + '\n', '')
file_text = \
file_text.replace(handle.lower() + '\n', '')
except OSError:
print('EX: unable to read noannounce: ' +
blocking_filename + ' ' + handle)
@ -749,7 +751,7 @@ def allowed_announce_remove(base_dir: str, nickname: str, domain: str,
blocking_filename = account_dir + '/noannounce.txt'
handle = following_nickname + '@' + following_domain
file_text = ''
if not text_in_file(handle + '\n', blocking_filename):
if not text_in_file(handle + '\n', blocking_filename, False):
try:
with open(blocking_filename, 'r',
encoding='utf-8') as fp_noannounce:

View File

@ -79,7 +79,7 @@ def receiving_calendar_events(base_dir: str, nickname: str, domain: str,
fp_cal.write(following_handles)
except OSError:
print('EX: receiving_calendar_events 2 ' + calendar_filename)
return _text_in_file2(handle + '\n', calendar_filename)
return _text_in_file2(handle + '\n', calendar_filename, False)
def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
@ -150,6 +150,20 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
fp_cal.write(following_handles)
except OSError:
print('EX: _receive_calendar_events 3 ' + calendar_filename)
elif handle + '\n' in following_handles.lower():
print(handle + ' exists in followingCalendar.txt')
if add:
# already added
return
# remove from calendar file
following_handles = \
following_handles.replace(handle.lower() + '\n', '')
try:
with open(calendar_filename, 'w+',
encoding='utf-8') as fp_cal:
fp_cal.write(following_handles)
except OSError:
print('EX: _receive_calendar_events 3 ' + calendar_filename)
else:
print(handle + ' not in followingCalendar.txt')
# not already in the calendar file

View File

@ -69,6 +69,17 @@ def _notify_on_post_arrival(base_dir: str, nickname: str, domain: str,
with open(notify_on_post_filename, 'w+',
encoding='utf-8') as fp_notify:
fp_notify.write(following_handles)
elif handle + '\n' in following_handles.lower():
print(handle + ' exists in notifyOnPost.txt')
if add:
# already added
return
# remove from calendar file
following_handles = \
following_handles.replace(handle.lower() + '\n', '')
with open(notify_on_post_filename, 'w+',
encoding='utf-8') as fp_notify:
fp_notify.write(following_handles)
else:
print(handle + ' not in notifyOnPost.txt')
# not already in the notifyOnPost file
@ -113,4 +124,4 @@ def notify_when_person_posts(base_dir: str, nickname: str, domain: str,
with open(notify_on_post_filename, 'w+',
encoding='utf-8') as fp_notify:
fp_notify.write('')
return text_in_file(handle + '\n', notify_on_post_filename)
return text_in_file(handle + '\n', notify_on_post_filename, False)