mirror of https://gitlab.com/bashrc2/epicyon
Replace file operations with functions
parent
9d2136314a
commit
7c883cf255
|
|
@ -148,6 +148,7 @@ from cwlists import get_cw_list_variable
|
||||||
from cache import remove_avatar_from_cache
|
from cache import remove_avatar_from_cache
|
||||||
from cache import store_person_in_cache
|
from cache import store_person_in_cache
|
||||||
from daemon_utils import post_to_outbox
|
from daemon_utils import post_to_outbox
|
||||||
|
from data import save_string
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
def _profile_post_deactivate_account(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -250,12 +251,9 @@ def _profile_post_git_projects(base_dir: str, nickname: str, domain: str,
|
||||||
git_projects_filename = \
|
git_projects_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/gitprojects.txt'
|
acct_dir(base_dir, nickname, domain) + '/gitprojects.txt'
|
||||||
if fields.get('gitProjects'):
|
if fields.get('gitProjects'):
|
||||||
try:
|
text = fields['gitProjects'].lower()
|
||||||
with open(git_projects_filename, 'w+',
|
save_string(text, git_projects_filename,
|
||||||
encoding='utf-8') as fp_git:
|
'EX: unable to write git ' + git_projects_filename)
|
||||||
fp_git.write(fields['gitProjects'].lower())
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write git ' + git_projects_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(git_projects_filename):
|
if os.path.isfile(git_projects_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -272,13 +270,9 @@ def _profile_post_peertube_instances(base_dir: str, fields: {}, self,
|
||||||
peertube_instances_file = data_dir(base_dir) + '/peertube.txt'
|
peertube_instances_file = data_dir(base_dir) + '/peertube.txt'
|
||||||
if fields.get('ptInstances'):
|
if fields.get('ptInstances'):
|
||||||
peertube_instances.clear()
|
peertube_instances.clear()
|
||||||
try:
|
save_string(fields['ptInstances'], peertube_instances_file,
|
||||||
with open(peertube_instances_file, 'w+',
|
'EX: unable to write peertube ' +
|
||||||
encoding='utf-8') as fp_peertube:
|
peertube_instances_file)
|
||||||
fp_peertube.write(fields['ptInstances'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write peertube ' +
|
|
||||||
peertube_instances_file)
|
|
||||||
pt_instances_list = fields['ptInstances'].split('\n')
|
pt_instances_list = fields['ptInstances'].split('\n')
|
||||||
if pt_instances_list:
|
if pt_instances_list:
|
||||||
for url in pt_instances_list:
|
for url in pt_instances_list:
|
||||||
|
|
@ -331,13 +325,9 @@ def _profile_post_robots_txt(base_dir: str, fields: {}, self) -> None:
|
||||||
' unable to delete ' +
|
' unable to delete ' +
|
||||||
robots_txt_filename)
|
robots_txt_filename)
|
||||||
else:
|
else:
|
||||||
try:
|
save_string(new_robots_txt, robots_txt_filename,
|
||||||
with open(robots_txt_filename, 'w+',
|
'EX: _profile_post_robots_txt unable to save ' +
|
||||||
encoding='utf-8') as fp_robots:
|
robots_txt_filename)
|
||||||
fp_robots.write(new_robots_txt)
|
|
||||||
except OSError:
|
|
||||||
print('EX: _profile_post_robots_txt unable to save ' +
|
|
||||||
robots_txt_filename)
|
|
||||||
|
|
||||||
self.server.robots_txt = new_robots_txt
|
self.server.robots_txt = new_robots_txt
|
||||||
|
|
||||||
|
|
@ -449,13 +439,9 @@ def _profile_post_allowed_instances(base_dir: str, nickname: str, domain: str,
|
||||||
acct_dir(base_dir, nickname, domain) + '/allowedinstances.txt'
|
acct_dir(base_dir, nickname, domain) + '/allowedinstances.txt'
|
||||||
if fields.get('allowedInstances'):
|
if fields.get('allowedInstances'):
|
||||||
inst_filename = allowed_instances_filename
|
inst_filename = allowed_instances_filename
|
||||||
try:
|
save_string(fields['allowedInstances'], inst_filename,
|
||||||
with open(inst_filename, 'w+',
|
'EX: unable to write allowed instances ' +
|
||||||
encoding='utf-8') as fp_inst:
|
allowed_instances_filename)
|
||||||
fp_inst.write(fields['allowedInstances'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowed instances ' +
|
|
||||||
allowed_instances_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowed_instances_filename):
|
if os.path.isfile(allowed_instances_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -475,13 +461,10 @@ def _profile_post_dm_instances(base_dir: str, nickname: str, domain: str,
|
||||||
dm_allowed_instances_filename = \
|
dm_allowed_instances_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/dmAllowedInstances.txt'
|
acct_dir(base_dir, nickname, domain) + '/dmAllowedInstances.txt'
|
||||||
if fields.get('dmAllowedInstances'):
|
if fields.get('dmAllowedInstances'):
|
||||||
try:
|
save_string(fields['dmAllowedInstances'],
|
||||||
with open(dm_allowed_instances_filename, 'w+',
|
dm_allowed_instances_filename,
|
||||||
encoding='utf-8') as fp_dm:
|
'EX: unable to write allowed DM instances ' +
|
||||||
fp_dm.write(fields['dmAllowedInstances'])
|
dm_allowed_instances_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowed DM instances ' +
|
|
||||||
dm_allowed_instances_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(dm_allowed_instances_filename):
|
if os.path.isfile(dm_allowed_instances_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -523,13 +506,9 @@ def _profile_post_import_follows(base_dir: str, nickname: str, domain: str,
|
||||||
follows_str = fields['importFollows']
|
follows_str = fields['importFollows']
|
||||||
while follows_str.startswith('\n'):
|
while follows_str.startswith('\n'):
|
||||||
follows_str = follows_str[1:]
|
follows_str = follows_str[1:]
|
||||||
try:
|
save_string(follows_str, filename_base,
|
||||||
with open(filename_base, 'w+',
|
'EX: unable to write imported follows ' +
|
||||||
encoding='utf-8') as fp_foll:
|
filename_base)
|
||||||
fp_foll.write(follows_str)
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write imported follows ' +
|
|
||||||
filename_base)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_import_blocks_csv(base_dir: str, nickname: str, domain: str,
|
def _profile_post_import_blocks_csv(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -555,13 +534,9 @@ def _profile_post_auto_cw(base_dir: str, nickname: str, domain: str,
|
||||||
auto_cw_filename = \
|
auto_cw_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/autocw.txt'
|
acct_dir(base_dir, nickname, domain) + '/autocw.txt'
|
||||||
if fields.get('autoCW'):
|
if fields.get('autoCW'):
|
||||||
try:
|
save_string(fields['autoCW'], auto_cw_filename,
|
||||||
with open(auto_cw_filename, 'w+',
|
'EX: unable to write auto CW ' +
|
||||||
encoding='utf-8') as fp_auto_cw:
|
auto_cw_filename)
|
||||||
fp_auto_cw.write(fields['autoCW'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write auto CW ' +
|
|
||||||
auto_cw_filename)
|
|
||||||
self.server.auto_cw_cache[nickname] = fields['autoCW'].split('\n')
|
self.server.auto_cw_cache[nickname] = fields['autoCW'].split('\n')
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_cw_filename):
|
if os.path.isfile(auto_cw_filename):
|
||||||
|
|
@ -582,13 +557,9 @@ def _profile_post_autogenerated_tags(base_dir: str,
|
||||||
auto_tags_filename = \
|
auto_tags_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/autotags.txt'
|
acct_dir(base_dir, nickname, domain) + '/autotags.txt'
|
||||||
if fields.get('autoTags'):
|
if fields.get('autoTags'):
|
||||||
try:
|
save_string(fields['autoTags'], auto_tags_filename,
|
||||||
with open(auto_tags_filename, 'w+',
|
'EX: unable to write auto tags ' +
|
||||||
encoding='utf-8') as fp_auto:
|
auto_tags_filename)
|
||||||
fp_auto.write(fields['autoTags'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write auto tags ' +
|
|
||||||
auto_tags_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_tags_filename):
|
if os.path.isfile(auto_tags_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -606,13 +577,9 @@ def _profile_post_word_replacements(base_dir: str,
|
||||||
switch_filename = \
|
switch_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/replacewords.txt'
|
acct_dir(base_dir, nickname, domain) + '/replacewords.txt'
|
||||||
if fields.get('switchwords'):
|
if fields.get('switchwords'):
|
||||||
try:
|
save_string(fields['switchwords'], switch_filename,
|
||||||
with open(switch_filename, 'w+',
|
'EX: unable to write switches ' +
|
||||||
encoding='utf-8') as fp_switch:
|
switch_filename)
|
||||||
fp_switch.write(fields['switchwords'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write switches ' +
|
|
||||||
switch_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(switch_filename):
|
if os.path.isfile(switch_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -631,13 +598,9 @@ def _profile_post_filtered_words_within_bio(base_dir: str,
|
||||||
filter_bio_filename = \
|
filter_bio_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + '/filters_bio.txt'
|
acct_dir(base_dir, nickname, domain) + '/filters_bio.txt'
|
||||||
if fields.get('filteredWordsBio'):
|
if fields.get('filteredWordsBio'):
|
||||||
try:
|
save_string(fields['filteredWordsBio'], filter_bio_filename,
|
||||||
with open(filter_bio_filename, 'w+',
|
'EX: unable to write bio filter ' +
|
||||||
encoding='utf-8') as fp_filter:
|
filter_bio_filename)
|
||||||
fp_filter.write(fields['filteredWordsBio'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write bio filter ' +
|
|
||||||
filter_bio_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_bio_filename):
|
if os.path.isfile(filter_bio_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -654,13 +617,9 @@ def _profile_post_filtered_words(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
filter_filename = acct_dir(base_dir, nickname, domain) + '/filters.txt'
|
filter_filename = acct_dir(base_dir, nickname, domain) + '/filters.txt'
|
||||||
if fields.get('filteredWords'):
|
if fields.get('filteredWords'):
|
||||||
try:
|
save_string(fields['filteredWords'], filter_filename,
|
||||||
with open(filter_filename, 'w+',
|
'EX: unable to write filter ' +
|
||||||
encoding='utf-8') as fp_filter:
|
filter_filename)
|
||||||
fp_filter.write(fields['filteredWords'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write filter ' +
|
|
||||||
filter_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_filename):
|
if os.path.isfile(filter_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -773,13 +732,9 @@ def _profile_post_notify_reactions(base_dir: str,
|
||||||
if on_final_welcome_screen:
|
if on_final_welcome_screen:
|
||||||
# default setting from welcome screen
|
# default setting from welcome screen
|
||||||
notify_react_filename = notify_reactions_filename
|
notify_react_filename = notify_reactions_filename
|
||||||
try:
|
save_string('\n', notify_react_filename,
|
||||||
with open(notify_react_filename, 'w+',
|
'EX: unable to write notify reactions ' +
|
||||||
encoding='utf-8') as fp_notify:
|
notify_reactions_filename)
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify reactions ' +
|
|
||||||
notify_reactions_filename)
|
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
notify_reactions_active = False
|
notify_reactions_active = False
|
||||||
|
|
@ -787,14 +742,10 @@ def _profile_post_notify_reactions(base_dir: str,
|
||||||
if fields['notifyReactions'] == 'on' and \
|
if fields['notifyReactions'] == 'on' and \
|
||||||
not hide_reaction_button_active:
|
not hide_reaction_button_active:
|
||||||
notify_reactions_active = True
|
notify_reactions_active = True
|
||||||
try:
|
save_string('\n', notify_reactions_filename,
|
||||||
with open(notify_reactions_filename, 'w+',
|
'EX: unable to write ' +
|
||||||
encoding='utf-8') as fp_notify:
|
'notify reactions ' +
|
||||||
fp_notify.write('\n')
|
notify_reactions_filename)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write ' +
|
|
||||||
'notify reactions ' +
|
|
||||||
notify_reactions_filename)
|
|
||||||
if not notify_reactions_active:
|
if not notify_reactions_active:
|
||||||
if os.path.isfile(notify_reactions_filename):
|
if os.path.isfile(notify_reactions_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -815,13 +766,9 @@ def _profile_post_notify_likes(on_final_welcome_screen: bool,
|
||||||
"""
|
"""
|
||||||
if on_final_welcome_screen:
|
if on_final_welcome_screen:
|
||||||
# default setting from welcome screen
|
# default setting from welcome screen
|
||||||
try:
|
save_string('\n', notify_likes_filename,
|
||||||
with open(notify_likes_filename, 'w+',
|
'EX: unable to write notify likes ' +
|
||||||
encoding='utf-8') as fp_notify:
|
notify_likes_filename)
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify likes ' +
|
|
||||||
notify_likes_filename)
|
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
notify_likes_active = False
|
notify_likes_active = False
|
||||||
|
|
@ -829,13 +776,9 @@ def _profile_post_notify_likes(on_final_welcome_screen: bool,
|
||||||
if fields['notifyLikes'] == 'on' and \
|
if fields['notifyLikes'] == 'on' and \
|
||||||
not hide_like_button_active:
|
not hide_like_button_active:
|
||||||
notify_likes_active = True
|
notify_likes_active = True
|
||||||
try:
|
save_string('\n', notify_likes_filename,
|
||||||
with open(notify_likes_filename, 'w+',
|
'EX: unable to write notify likes ' +
|
||||||
encoding='utf-8') as fp_notify:
|
notify_likes_filename)
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify likes ' +
|
|
||||||
notify_likes_filename)
|
|
||||||
if not notify_likes_active:
|
if not notify_likes_active:
|
||||||
if os.path.isfile(notify_likes_filename):
|
if os.path.isfile(notify_likes_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -935,13 +878,9 @@ def _profile_post_no_reply_boosts(base_dir: str, nickname: str, domain: str,
|
||||||
no_reply_boosts = True
|
no_reply_boosts = True
|
||||||
if no_reply_boosts:
|
if no_reply_boosts:
|
||||||
if not os.path.isfile(no_reply_boosts_filename):
|
if not os.path.isfile(no_reply_boosts_filename):
|
||||||
try:
|
save_string('\n', no_reply_boosts_filename,
|
||||||
with open(no_reply_boosts_filename, 'w+',
|
'EX: unable to write noReplyBoosts ' +
|
||||||
encoding='utf-8') as fp_reply:
|
no_reply_boosts_filename)
|
||||||
fp_reply.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noReplyBoosts ' +
|
|
||||||
no_reply_boosts_filename)
|
|
||||||
if not no_reply_boosts:
|
if not no_reply_boosts:
|
||||||
if os.path.isfile(no_reply_boosts_filename):
|
if os.path.isfile(no_reply_boosts_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -964,13 +903,9 @@ def _profile_post_no_seen_posts(base_dir: str, nickname: str, domain: str,
|
||||||
no_seen_posts = True
|
no_seen_posts = True
|
||||||
if no_seen_posts:
|
if no_seen_posts:
|
||||||
if not os.path.isfile(no_seen_posts_filename):
|
if not os.path.isfile(no_seen_posts_filename):
|
||||||
try:
|
save_string('\n', no_seen_posts_filename,
|
||||||
with open(no_seen_posts_filename, 'w+',
|
'EX: unable to write noSeenPosts ' +
|
||||||
encoding='utf-8') as fp_seen:
|
no_seen_posts_filename)
|
||||||
fp_seen.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noSeenPosts ' +
|
|
||||||
no_seen_posts_filename)
|
|
||||||
if not no_seen_posts:
|
if not no_seen_posts:
|
||||||
if os.path.isfile(no_seen_posts_filename):
|
if os.path.isfile(no_seen_posts_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -994,13 +929,9 @@ def _profile_post_watermark_enabled(base_dir: str,
|
||||||
watermark_enabled = True
|
watermark_enabled = True
|
||||||
if watermark_enabled:
|
if watermark_enabled:
|
||||||
if not os.path.isfile(watermark_enabled_filename):
|
if not os.path.isfile(watermark_enabled_filename):
|
||||||
try:
|
save_string('\n', watermark_enabled_filename,
|
||||||
with open(watermark_enabled_filename, 'w+',
|
'EX: unable to write watermarkEnabled ' +
|
||||||
encoding='utf-8') as fp_wm:
|
watermark_enabled_filename)
|
||||||
fp_wm.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write watermarkEnabled ' +
|
|
||||||
watermark_enabled_filename)
|
|
||||||
if not watermark_enabled:
|
if not watermark_enabled:
|
||||||
if os.path.isfile(watermark_enabled_filename):
|
if os.path.isfile(watermark_enabled_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1029,13 +960,9 @@ def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
||||||
actor_json['hideFollows'] = True
|
actor_json['hideFollows'] = True
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
if not os.path.isfile(hide_follows_filename):
|
if not os.path.isfile(hide_follows_filename):
|
||||||
try:
|
save_string('\n', hide_follows_filename,
|
||||||
with open(hide_follows_filename, 'w+',
|
'EX: unable to write hideFollows ' +
|
||||||
encoding='utf-8') as fp_hide:
|
hide_follows_filename)
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hideFollows ' +
|
|
||||||
hide_follows_filename)
|
|
||||||
if not hide_follows:
|
if not hide_follows:
|
||||||
actor_json['hideFollows'] = False
|
actor_json['hideFollows'] = False
|
||||||
if self.server.hide_follows.get(nickname):
|
if self.server.hide_follows.get(nickname):
|
||||||
|
|
@ -1069,13 +996,9 @@ def _profile_post_hide_recent_posts(base_dir: str, nickname: str, domain: str,
|
||||||
actor_json['hideRecentPosts'] = True
|
actor_json['hideRecentPosts'] = True
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
if not os.path.isfile(hide_recent_posts_filename):
|
if not os.path.isfile(hide_recent_posts_filename):
|
||||||
try:
|
save_string('\n', hide_recent_posts_filename,
|
||||||
with open(hide_recent_posts_filename, 'w+',
|
'EX: unable to write hideRecentPosts ' +
|
||||||
encoding='utf-8') as fp_hide:
|
hide_recent_posts_filename)
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hideRecentPosts ' +
|
|
||||||
hide_recent_posts_filename)
|
|
||||||
if not hide_recent_posts:
|
if not hide_recent_posts:
|
||||||
actor_json['hideRecentPosts'] = False
|
actor_json['hideRecentPosts'] = False
|
||||||
if self.server.hide_recent_posts.get(nickname):
|
if self.server.hide_recent_posts.get(nickname):
|
||||||
|
|
@ -1108,13 +1031,9 @@ def _profile_post_mutuals_replies(account_dir: str, fields: {}) -> None:
|
||||||
show_replies_mutuals_file)
|
show_replies_mutuals_file)
|
||||||
else:
|
else:
|
||||||
if show_replies_mutuals:
|
if show_replies_mutuals:
|
||||||
try:
|
save_string('\n', show_replies_mutuals_file,
|
||||||
with open(show_replies_mutuals_file, 'w+',
|
'EX: unable to write repliesFromMutualsOnly file ' +
|
||||||
encoding='utf-8') as fp_replies:
|
show_replies_mutuals_file)
|
||||||
fp_replies.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write repliesFromMutualsOnly file ' +
|
|
||||||
show_replies_mutuals_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_only_follower_replies(fields: {},
|
def _profile_post_only_follower_replies(fields: {},
|
||||||
|
|
@ -1136,14 +1055,10 @@ def _profile_post_only_follower_replies(fields: {},
|
||||||
show_replies_followers_file)
|
show_replies_followers_file)
|
||||||
else:
|
else:
|
||||||
if show_replies_followers:
|
if show_replies_followers:
|
||||||
try:
|
save_string('\n', show_replies_followers_file,
|
||||||
with open(show_replies_followers_file, 'w+',
|
'EX: unable to write ' +
|
||||||
encoding='utf-8') as fp_replies:
|
'repliesFromFollowersOnly file ' +
|
||||||
fp_replies.write('\n')
|
show_replies_followers_file)
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write ' +
|
|
||||||
'repliesFromFollowersOnly file ' +
|
|
||||||
show_replies_followers_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_show_quote_toots(fields: {}, account_dir: str) -> None:
|
def _profile_post_show_quote_toots(fields: {}, account_dir: str) -> None:
|
||||||
|
|
@ -1163,13 +1078,9 @@ def _profile_post_show_quote_toots(fields: {}, account_dir: str) -> None:
|
||||||
show_quote_toots_file)
|
show_quote_toots_file)
|
||||||
else:
|
else:
|
||||||
if show_quote_toots:
|
if show_quote_toots:
|
||||||
try:
|
save_string('\n', show_quote_toots_file,
|
||||||
with open(show_quote_toots_file, 'w+',
|
'EX: unable to write allowQuotes file ' +
|
||||||
encoding='utf-8') as fp_quotes:
|
show_quote_toots_file)
|
||||||
fp_quotes.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowQuotes file ' +
|
|
||||||
show_quote_toots_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_show_questions(fields: {}, account_dir: str) -> None:
|
def _profile_post_show_questions(fields: {}, account_dir: str) -> None:
|
||||||
|
|
@ -1189,13 +1100,9 @@ def _profile_post_show_questions(fields: {}, account_dir: str) -> None:
|
||||||
show_vote_file)
|
show_vote_file)
|
||||||
else:
|
else:
|
||||||
if not show_vote_posts:
|
if not show_vote_posts:
|
||||||
try:
|
save_string('\n', show_vote_file,
|
||||||
with open(show_vote_file, 'w+',
|
'EX: unable to write noVotes file ' +
|
||||||
encoding='utf-8') as fp_votes:
|
show_vote_file)
|
||||||
fp_votes.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noVotes file ' +
|
|
||||||
show_vote_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_reverse_timelines(base_dir: str, nickname: str,
|
def _profile_post_reverse_timelines(base_dir: str, nickname: str,
|
||||||
|
|
@ -1229,13 +1136,9 @@ def _profile_post_bold_reading(base_dir: str,
|
||||||
if fields['boldReading'] == 'on':
|
if fields['boldReading'] == 'on':
|
||||||
bold_reading = True
|
bold_reading = True
|
||||||
self.server.bold_reading[nickname] = True
|
self.server.bold_reading[nickname] = True
|
||||||
try:
|
save_string('\n', bold_reading_filename,
|
||||||
with open(bold_reading_filename, 'w+',
|
'EX: unable to write bold reading ' +
|
||||||
encoding='utf-8') as fp_bold:
|
bold_reading_filename)
|
||||||
fp_bold.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write bold reading ' +
|
|
||||||
bold_reading_filename)
|
|
||||||
if not bold_reading:
|
if not bold_reading:
|
||||||
if self.server.bold_reading.get(nickname):
|
if self.server.bold_reading.get(nickname):
|
||||||
del self.server.bold_reading[nickname]
|
del self.server.bold_reading[nickname]
|
||||||
|
|
@ -1260,13 +1163,9 @@ def _profile_post_hide_reaction_button2(base_dir: str,
|
||||||
if fields.get('hideReactionButton'):
|
if fields.get('hideReactionButton'):
|
||||||
if fields['hideReactionButton'] == 'on':
|
if fields['hideReactionButton'] == 'on':
|
||||||
hide_reaction_button_active = True
|
hide_reaction_button_active = True
|
||||||
try:
|
save_string('\n', hide_reaction_button_file,
|
||||||
with open(hide_reaction_button_file, 'w+',
|
'EX: unable to write hide reaction ' +
|
||||||
encoding='utf-8') as fp_hide:
|
hide_reaction_button_file)
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hide reaction ' +
|
|
||||||
hide_reaction_button_file)
|
|
||||||
# remove notify Reaction selection
|
# remove notify Reaction selection
|
||||||
if os.path.isfile(notify_reactions_filename):
|
if os.path.isfile(notify_reactions_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1319,13 +1218,9 @@ def _profile_post_hide_like_button2(base_dir: str, nickname: str, domain: str,
|
||||||
if fields.get('hideLikeButton'):
|
if fields.get('hideLikeButton'):
|
||||||
if fields['hideLikeButton'] == 'on':
|
if fields['hideLikeButton'] == 'on':
|
||||||
hide_like_button_active = True
|
hide_like_button_active = True
|
||||||
try:
|
save_string('\n', hide_like_button_file,
|
||||||
with open(hide_like_button_file, 'w+',
|
'EX: unable to write hide like ' +
|
||||||
encoding='utf-8') as rfil:
|
hide_like_button_file)
|
||||||
rfil.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hide like ' +
|
|
||||||
hide_like_button_file)
|
|
||||||
# remove notify likes selection
|
# remove notify likes selection
|
||||||
if os.path.isfile(notify_likes_filename):
|
if os.path.isfile(notify_likes_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1352,13 +1247,9 @@ def _profile_post_remove_retweets(base_dir: str, nickname: str, domain: str,
|
||||||
if fields.get('removeTwitter'):
|
if fields.get('removeTwitter'):
|
||||||
if fields['removeTwitter'] == 'on':
|
if fields['removeTwitter'] == 'on':
|
||||||
remove_twitter_active = True
|
remove_twitter_active = True
|
||||||
try:
|
save_string('\n', remove_twitter_filename,
|
||||||
with open(remove_twitter_filename, 'w+',
|
'EX: unable to write remove twitter ' +
|
||||||
encoding='utf-8') as fp_remove:
|
remove_twitter_filename)
|
||||||
fp_remove.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write remove twitter ' +
|
|
||||||
remove_twitter_filename)
|
|
||||||
if not remove_twitter_active:
|
if not remove_twitter_active:
|
||||||
if os.path.isfile(remove_twitter_filename):
|
if os.path.isfile(remove_twitter_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1378,26 +1269,18 @@ def _profile_post_dms_from_followers(base_dir: str, nickname: str, domain: str,
|
||||||
if on_final_welcome_screen:
|
if on_final_welcome_screen:
|
||||||
# initial default setting created via
|
# initial default setting created via
|
||||||
# the welcome screen
|
# the welcome screen
|
||||||
try:
|
save_string('\n', follow_dms_filename,
|
||||||
with open(follow_dms_filename, 'w+',
|
'EX: unable to write follow DMs ' +
|
||||||
encoding='utf-8') as fp_foll:
|
follow_dms_filename)
|
||||||
fp_foll.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write follow DMs ' +
|
|
||||||
follow_dms_filename)
|
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
follow_dms_active = False
|
follow_dms_active = False
|
||||||
if fields.get('followDMs'):
|
if fields.get('followDMs'):
|
||||||
if fields['followDMs'] == 'on':
|
if fields['followDMs'] == 'on':
|
||||||
follow_dms_active = True
|
follow_dms_active = True
|
||||||
try:
|
save_string('\n', follow_dms_filename,
|
||||||
with open(follow_dms_filename, 'w+',
|
'EX: unable to write follow DMs 2 ' +
|
||||||
encoding='utf-8') as fp_foll:
|
follow_dms_filename)
|
||||||
fp_foll.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write follow DMs 2 ' +
|
|
||||||
follow_dms_filename)
|
|
||||||
if not follow_dms_active:
|
if not follow_dms_active:
|
||||||
if os.path.isfile(follow_dms_filename):
|
if os.path.isfile(follow_dms_filename):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1492,12 +1375,8 @@ def _profile_post_reject_spam_actors(base_dir: str,
|
||||||
curr_reject_spam_actors = True
|
curr_reject_spam_actors = True
|
||||||
if reject_spam_actors != curr_reject_spam_actors:
|
if reject_spam_actors != curr_reject_spam_actors:
|
||||||
if reject_spam_actors:
|
if reject_spam_actors:
|
||||||
try:
|
save_string('\n', actor_spam_filter_filename,
|
||||||
with open(actor_spam_filter_filename, 'w+',
|
'EX: unable to write reject spam actors')
|
||||||
encoding='utf-8') as fp_spam:
|
|
||||||
fp_spam.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write reject spam actors')
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.remove(actor_spam_filter_filename)
|
os.remove(actor_spam_filter_filename)
|
||||||
|
|
@ -1897,13 +1776,9 @@ def _profile_post_ntfy_topic(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('ntfyTopic'):
|
if fields.get('ntfyTopic'):
|
||||||
ntfy_topic_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_topic'
|
ntfy_topic_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_topic'
|
||||||
try:
|
save_string(fields['ntfyTopic'], ntfy_topic_file,
|
||||||
with open(ntfy_topic_file, 'w+',
|
'EX: unable to save ntfy topic ' +
|
||||||
encoding='utf-8') as fp_ntfy:
|
ntfy_topic_file)
|
||||||
fp_ntfy.write(fields['ntfyTopic'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to save ntfy topic ' +
|
|
||||||
ntfy_topic_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_ntfy_url(base_dir: str, nickname: str, domain: str,
|
def _profile_post_ntfy_url(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
@ -1912,13 +1787,9 @@ def _profile_post_ntfy_url(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('ntfyUrl'):
|
if fields.get('ntfyUrl'):
|
||||||
ntfy_url_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_url'
|
ntfy_url_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_url'
|
||||||
try:
|
save_string(fields['ntfyUrl'], ntfy_url_file,
|
||||||
with open(ntfy_url_file, 'w+',
|
'EX: unable to save ntfy url ' +
|
||||||
encoding='utf-8') as fp_ntfy:
|
ntfy_url_file)
|
||||||
fp_ntfy.write(fields['ntfyUrl'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to save ntfy url ' +
|
|
||||||
ntfy_url_file)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_cwtch_address(fields: {}, actor_json: {},
|
def _profile_post_cwtch_address(fields: {}, actor_json: {},
|
||||||
|
|
@ -2699,12 +2570,8 @@ def _profile_post_change_city(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('cityDropdown'):
|
if fields.get('cityDropdown'):
|
||||||
city_filename = acct_dir(base_dir, nickname, domain) + '/city.txt'
|
city_filename = acct_dir(base_dir, nickname, domain) + '/city.txt'
|
||||||
try:
|
save_string(fields['cityDropdown'], city_filename,
|
||||||
with open(city_filename, 'w+',
|
'EX: edit profile unable to write city ' + city_filename)
|
||||||
encoding='utf-8') as fp_city:
|
|
||||||
fp_city.write(fields['cityDropdown'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: edit profile unable to write city ' + city_filename)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_set_reply_interval(base_dir: str, nickname: str, domain: str,
|
def _profile_post_set_reply_interval(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue