mirror of https://gitlab.com/bashrc2/epicyon
Replace file operations with functions
parent
583a1ae83f
commit
0fe242c036
|
|
@ -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,12 +270,8 @@ 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:
|
|
||||||
fp_peertube.write(fields['ptInstances'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write peertube ' +
|
|
||||||
peertube_instances_file)
|
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:
|
||||||
|
|
@ -331,12 +325,8 @@ 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:
|
|
||||||
fp_robots.write(new_robots_txt)
|
|
||||||
except OSError:
|
|
||||||
print('EX: _profile_post_robots_txt unable to save ' +
|
|
||||||
robots_txt_filename)
|
robots_txt_filename)
|
||||||
|
|
||||||
self.server.robots_txt = new_robots_txt
|
self.server.robots_txt = new_robots_txt
|
||||||
|
|
@ -449,12 +439,8 @@ 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:
|
|
||||||
fp_inst.write(fields['allowedInstances'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowed instances ' +
|
|
||||||
allowed_instances_filename)
|
allowed_instances_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(allowed_instances_filename):
|
if os.path.isfile(allowed_instances_filename):
|
||||||
|
|
@ -475,12 +461,9 @@ 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'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowed DM instances ' +
|
|
||||||
dm_allowed_instances_filename)
|
dm_allowed_instances_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(dm_allowed_instances_filename):
|
if os.path.isfile(dm_allowed_instances_filename):
|
||||||
|
|
@ -523,12 +506,8 @@ 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:
|
|
||||||
fp_foll.write(follows_str)
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write imported follows ' +
|
|
||||||
filename_base)
|
filename_base)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -555,12 +534,8 @@ 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:
|
|
||||||
fp_auto_cw.write(fields['autoCW'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write auto CW ' +
|
|
||||||
auto_cw_filename)
|
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:
|
||||||
|
|
@ -582,12 +557,8 @@ 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:
|
|
||||||
fp_auto.write(fields['autoTags'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write auto tags ' +
|
|
||||||
auto_tags_filename)
|
auto_tags_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_tags_filename):
|
if os.path.isfile(auto_tags_filename):
|
||||||
|
|
@ -606,12 +577,8 @@ 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:
|
|
||||||
fp_switch.write(fields['switchwords'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write switches ' +
|
|
||||||
switch_filename)
|
switch_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(switch_filename):
|
if os.path.isfile(switch_filename):
|
||||||
|
|
@ -631,12 +598,8 @@ 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:
|
|
||||||
fp_filter.write(fields['filteredWordsBio'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write bio filter ' +
|
|
||||||
filter_bio_filename)
|
filter_bio_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_bio_filename):
|
if os.path.isfile(filter_bio_filename):
|
||||||
|
|
@ -654,12 +617,8 @@ 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:
|
|
||||||
fp_filter.write(fields['filteredWords'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write filter ' +
|
|
||||||
filter_filename)
|
filter_filename)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(filter_filename):
|
if os.path.isfile(filter_filename):
|
||||||
|
|
@ -773,12 +732,8 @@ 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:
|
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify reactions ' +
|
|
||||||
notify_reactions_filename)
|
notify_reactions_filename)
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -787,12 +742,8 @@ 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:
|
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write ' +
|
|
||||||
'notify reactions ' +
|
'notify reactions ' +
|
||||||
notify_reactions_filename)
|
notify_reactions_filename)
|
||||||
if not notify_reactions_active:
|
if not notify_reactions_active:
|
||||||
|
|
@ -815,12 +766,8 @@ 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:
|
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify likes ' +
|
|
||||||
notify_likes_filename)
|
notify_likes_filename)
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -829,12 +776,8 @@ 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:
|
|
||||||
fp_notify.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write notify likes ' +
|
|
||||||
notify_likes_filename)
|
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):
|
||||||
|
|
@ -935,12 +878,8 @@ 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:
|
|
||||||
fp_reply.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noReplyBoosts ' +
|
|
||||||
no_reply_boosts_filename)
|
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):
|
||||||
|
|
@ -964,12 +903,8 @@ 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:
|
|
||||||
fp_seen.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noSeenPosts ' +
|
|
||||||
no_seen_posts_filename)
|
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):
|
||||||
|
|
@ -994,12 +929,8 @@ 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:
|
|
||||||
fp_wm.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write watermarkEnabled ' +
|
|
||||||
watermark_enabled_filename)
|
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):
|
||||||
|
|
@ -1029,12 +960,8 @@ 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:
|
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hideFollows ' +
|
|
||||||
hide_follows_filename)
|
hide_follows_filename)
|
||||||
if not hide_follows:
|
if not hide_follows:
|
||||||
actor_json['hideFollows'] = False
|
actor_json['hideFollows'] = False
|
||||||
|
|
@ -1069,12 +996,8 @@ 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:
|
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hideRecentPosts ' +
|
|
||||||
hide_recent_posts_filename)
|
hide_recent_posts_filename)
|
||||||
if not hide_recent_posts:
|
if not hide_recent_posts:
|
||||||
actor_json['hideRecentPosts'] = False
|
actor_json['hideRecentPosts'] = False
|
||||||
|
|
@ -1108,12 +1031,8 @@ 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:
|
|
||||||
fp_replies.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write repliesFromMutualsOnly file ' +
|
|
||||||
show_replies_mutuals_file)
|
show_replies_mutuals_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1136,12 +1055,8 @@ 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:
|
|
||||||
fp_replies.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write ' +
|
|
||||||
'repliesFromFollowersOnly file ' +
|
'repliesFromFollowersOnly file ' +
|
||||||
show_replies_followers_file)
|
show_replies_followers_file)
|
||||||
|
|
||||||
|
|
@ -1163,12 +1078,8 @@ 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:
|
|
||||||
fp_quotes.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write allowQuotes file ' +
|
|
||||||
show_quote_toots_file)
|
show_quote_toots_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1189,12 +1100,8 @@ 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:
|
|
||||||
fp_votes.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write noVotes file ' +
|
|
||||||
show_vote_file)
|
show_vote_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1229,12 +1136,8 @@ 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:
|
|
||||||
fp_bold.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write bold reading ' +
|
|
||||||
bold_reading_filename)
|
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):
|
||||||
|
|
@ -1260,12 +1163,8 @@ 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:
|
|
||||||
fp_hide.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hide reaction ' +
|
|
||||||
hide_reaction_button_file)
|
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):
|
||||||
|
|
@ -1319,12 +1218,8 @@ 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:
|
|
||||||
rfil.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write hide like ' +
|
|
||||||
hide_like_button_file)
|
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):
|
||||||
|
|
@ -1352,12 +1247,8 @@ 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:
|
|
||||||
fp_remove.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write remove twitter ' +
|
|
||||||
remove_twitter_filename)
|
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):
|
||||||
|
|
@ -1378,12 +1269,8 @@ 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:
|
|
||||||
fp_foll.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write follow DMs ' +
|
|
||||||
follow_dms_filename)
|
follow_dms_filename)
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -1391,12 +1278,8 @@ def _profile_post_dms_from_followers(base_dir: str, nickname: str, domain: str,
|
||||||
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:
|
|
||||||
fp_foll.write('\n')
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to write follow DMs 2 ' +
|
|
||||||
follow_dms_filename)
|
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):
|
||||||
|
|
@ -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,12 +1776,8 @@ 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:
|
|
||||||
fp_ntfy.write(fields['ntfyTopic'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to save ntfy topic ' +
|
|
||||||
ntfy_topic_file)
|
ntfy_topic_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1912,12 +1787,8 @@ 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:
|
|
||||||
fp_ntfy.write(fields['ntfyUrl'])
|
|
||||||
except OSError:
|
|
||||||
print('EX: unable to save ntfy url ' +
|
|
||||||
ntfy_url_file)
|
ntfy_url_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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