mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
049336d26c
commit
0e39026d6e
|
@ -159,25 +159,20 @@ def _profile_post_save_actor(base_dir: str, http_prefix: str,
|
||||||
if actor_json.get('nomadicLocations'):
|
if actor_json.get('nomadicLocations'):
|
||||||
del actor_json['nomadicLocations']
|
del actor_json['nomadicLocations']
|
||||||
if not actor_json.get('featured'):
|
if not actor_json.get('featured'):
|
||||||
actor_json['featured'] = \
|
actor_json['featured'] = actor_json['id'] + '/collections/featured'
|
||||||
actor_json['id'] + '/collections/featured'
|
|
||||||
if not actor_json.get('featuredTags'):
|
if not actor_json.get('featuredTags'):
|
||||||
actor_json['featuredTags'] = \
|
actor_json['featuredTags'] = actor_json['id'] + '/collections/tags'
|
||||||
actor_json['id'] + '/collections/tags'
|
|
||||||
randomize_actor_images(actor_json)
|
randomize_actor_images(actor_json)
|
||||||
add_actor_update_timestamp(actor_json)
|
add_actor_update_timestamp(actor_json)
|
||||||
# save the actor
|
# save the actor
|
||||||
save_json(actor_json, actor_filename)
|
save_json(actor_json, actor_filename)
|
||||||
webfinger_update(base_dir,
|
webfinger_update(base_dir, nickname, domain,
|
||||||
nickname, domain,
|
|
||||||
onion_domain, i2p_domain,
|
onion_domain, i2p_domain,
|
||||||
self.server.cached_webfingers)
|
self.server.cached_webfingers)
|
||||||
# also copy to the actors cache and
|
# also copy to the actors cache and
|
||||||
# person_cache in memory
|
# person_cache in memory
|
||||||
store_person_in_cache(base_dir,
|
store_person_in_cache(base_dir, actor_json['id'], actor_json,
|
||||||
actor_json['id'], actor_json,
|
self.server.person_cache, True)
|
||||||
self.server.person_cache,
|
|
||||||
True)
|
|
||||||
# clear any cached images for this actor
|
# clear any cached images for this actor
|
||||||
id_str = actor_json['id'].replace('/', '-')
|
id_str = actor_json['id'].replace('/', '-')
|
||||||
remove_avatar_from_cache(base_dir, id_str)
|
remove_avatar_from_cache(base_dir, id_str)
|
||||||
|
@ -188,17 +183,14 @@ def _profile_post_save_actor(base_dir: str, http_prefix: str,
|
||||||
save_json(actor_json, actor_cache_filename)
|
save_json(actor_json, actor_cache_filename)
|
||||||
# send profile update to followers
|
# send profile update to followers
|
||||||
update_actor_json = get_actor_update_json(actor_json)
|
update_actor_json = get_actor_update_json(actor_json)
|
||||||
print('Sending actor update: ' +
|
print('Sending actor update: ' + str(update_actor_json))
|
||||||
str(update_actor_json))
|
|
||||||
post_to_outbox(self, update_actor_json,
|
post_to_outbox(self, update_actor_json,
|
||||||
self.server.project_version,
|
self.server.project_version, nickname,
|
||||||
nickname,
|
|
||||||
curr_session, proxy_type)
|
curr_session, proxy_type)
|
||||||
# send move activity if necessary
|
# send move activity if necessary
|
||||||
if send_move_activity:
|
if send_move_activity:
|
||||||
move_actor_json = get_actor_move_json(actor_json)
|
move_actor_json = get_actor_move_json(actor_json)
|
||||||
print('Sending Move activity: ' +
|
print('Sending Move activity: ' + str(move_actor_json))
|
||||||
str(move_actor_json))
|
|
||||||
post_to_outbox(self, move_actor_json,
|
post_to_outbox(self, move_actor_json,
|
||||||
self.server.project_version,
|
self.server.project_version,
|
||||||
nickname,
|
nickname,
|
||||||
|
@ -232,15 +224,13 @@ def _profile_post_git_projects(base_dir: str, nickname: str, domain: str,
|
||||||
encoding='utf-8') as afile:
|
encoding='utf-8') as afile:
|
||||||
afile.write(fields['gitProjects'].lower())
|
afile.write(fields['gitProjects'].lower())
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write git ' +
|
print('EX: unable to write git ' + git_projects_filename)
|
||||||
git_projects_filename)
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(git_projects_filename):
|
if os.path.isfile(git_projects_filename):
|
||||||
try:
|
try:
|
||||||
os.remove(git_projects_filename)
|
os.remove(git_projects_filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _profile_edit ' +
|
print('EX: _profile_edit unable to delete ' +
|
||||||
'unable to delete ' +
|
|
||||||
git_projects_filename)
|
git_projects_filename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,8 +247,7 @@ def _profile_post_peertube_instances(base_dir: str, fields: {}, self) -> None:
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write peertube ' +
|
print('EX: unable to write peertube ' +
|
||||||
peertube_instances_file)
|
peertube_instances_file)
|
||||||
pt_instances_list = \
|
pt_instances_list = fields['ptInstances'].split('\n')
|
||||||
fields['ptInstances'].split('\n')
|
|
||||||
if pt_instances_list:
|
if pt_instances_list:
|
||||||
for url in pt_instances_list:
|
for url in pt_instances_list:
|
||||||
url = url.strip()
|
url = url.strip()
|
||||||
|
@ -272,8 +261,7 @@ def _profile_post_peertube_instances(base_dir: str, fields: {}, self) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(peertube_instances_file)
|
os.remove(peertube_instances_file)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _profile_edit ' +
|
print('EX: _profile_edit unable to delete ' +
|
||||||
'unable to delete ' +
|
|
||||||
peertube_instances_file)
|
peertube_instances_file)
|
||||||
self.server.peertube_instances.clear()
|
self.server.peertube_instances.clear()
|
||||||
|
|
||||||
|
@ -283,12 +271,9 @@ def _profile_post_block_federated(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
block_ep_new = []
|
block_ep_new = []
|
||||||
if fields.get('blockFederated'):
|
if fields.get('blockFederated'):
|
||||||
block_federated_str = \
|
block_federated_str = fields['blockFederated']
|
||||||
fields['blockFederated']
|
block_ep_new = block_federated_str.split('\n')
|
||||||
block_ep_new = \
|
if str(self.server.block_federated_endpoints) != str(block_ep_new):
|
||||||
block_federated_str.split('\n')
|
|
||||||
if str(self.server.block_federated_endpoints) != \
|
|
||||||
str(block_ep_new):
|
|
||||||
self.server.block_federated_endpoints = \
|
self.server.block_federated_endpoints = \
|
||||||
save_block_federated_endpoints(base_dir,
|
save_block_federated_endpoints(base_dir,
|
||||||
block_ep_new)
|
block_ep_new)
|
||||||
|
@ -301,15 +286,12 @@ def _profile_post_buy_domains(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
buy_sites = {}
|
buy_sites = {}
|
||||||
if fields.get('buySitesStr'):
|
if fields.get('buySitesStr'):
|
||||||
buy_sites_str = \
|
buy_sites_str = fields['buySitesStr']
|
||||||
fields['buySitesStr']
|
buy_sites_list = buy_sites_str.split('\n')
|
||||||
buy_sites_list = \
|
|
||||||
buy_sites_str.split('\n')
|
|
||||||
for site_url in buy_sites_list:
|
for site_url in buy_sites_list:
|
||||||
if ' ' in site_url:
|
if ' ' in site_url:
|
||||||
site_url = site_url.split(' ')[-1]
|
site_url = site_url.split(' ')[-1]
|
||||||
buy_icon_text = \
|
buy_icon_text = site_url.replace(site_url, '').strip()
|
||||||
site_url.replace(site_url, '').strip()
|
|
||||||
if not buy_icon_text:
|
if not buy_icon_text:
|
||||||
buy_icon_text = site_url
|
buy_icon_text = site_url
|
||||||
else:
|
else:
|
||||||
|
@ -321,11 +303,9 @@ def _profile_post_buy_domains(base_dir: str, fields: {}, self) -> None:
|
||||||
if not site_url.strip():
|
if not site_url.strip():
|
||||||
continue
|
continue
|
||||||
buy_sites[buy_icon_text] = site_url.strip()
|
buy_sites[buy_icon_text] = site_url.strip()
|
||||||
if str(self.server.buy_sites) != \
|
if str(self.server.buy_sites) != str(buy_sites):
|
||||||
str(buy_sites):
|
|
||||||
self.server.buy_sites = buy_sites
|
self.server.buy_sites = buy_sites
|
||||||
buy_sites_filename = \
|
buy_sites_filename = base_dir + '/accounts/buy_sites.json'
|
||||||
base_dir + '/accounts/buy_sites.json'
|
|
||||||
if buy_sites:
|
if buy_sites:
|
||||||
save_json(buy_sites, buy_sites_filename)
|
save_json(buy_sites, buy_sites_filename)
|
||||||
else:
|
else:
|
||||||
|
@ -342,18 +322,14 @@ def _profile_post_crawlers_allowed(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
crawlers_allowed = []
|
crawlers_allowed = []
|
||||||
if fields.get('crawlersAllowedStr'):
|
if fields.get('crawlersAllowedStr'):
|
||||||
crawlers_allowed_str = \
|
crawlers_allowed_str = fields['crawlersAllowedStr']
|
||||||
fields['crawlersAllowedStr']
|
crawlers_allowed_list = crawlers_allowed_str.split('\n')
|
||||||
crawlers_allowed_list = \
|
|
||||||
crawlers_allowed_str.split('\n')
|
|
||||||
for uagent in crawlers_allowed_list:
|
for uagent in crawlers_allowed_list:
|
||||||
if uagent in crawlers_allowed:
|
if uagent in crawlers_allowed:
|
||||||
continue
|
continue
|
||||||
crawlers_allowed.append(uagent.strip())
|
crawlers_allowed.append(uagent.strip())
|
||||||
if str(self.server.crawlers_allowed) != \
|
if str(self.server.crawlers_allowed) != str(crawlers_allowed):
|
||||||
str(crawlers_allowed):
|
self.server.crawlers_allowed = crawlers_allowed
|
||||||
self.server.crawlers_allowed = \
|
|
||||||
crawlers_allowed
|
|
||||||
crawlers_allowed_str = ''
|
crawlers_allowed_str = ''
|
||||||
for uagent in crawlers_allowed:
|
for uagent in crawlers_allowed:
|
||||||
if crawlers_allowed_str:
|
if crawlers_allowed_str:
|
||||||
|
@ -368,18 +344,14 @@ def _profile_post_blocked_user_agents(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
user_agents_blocked = []
|
user_agents_blocked = []
|
||||||
if fields.get('userAgentsBlockedStr'):
|
if fields.get('userAgentsBlockedStr'):
|
||||||
user_agents_blocked_str = \
|
user_agents_blocked_str = fields['userAgentsBlockedStr']
|
||||||
fields['userAgentsBlockedStr']
|
user_agents_blocked_list = user_agents_blocked_str.split('\n')
|
||||||
user_agents_blocked_list = \
|
|
||||||
user_agents_blocked_str.split('\n')
|
|
||||||
for uagent in user_agents_blocked_list:
|
for uagent in user_agents_blocked_list:
|
||||||
if uagent in user_agents_blocked:
|
if uagent in user_agents_blocked:
|
||||||
continue
|
continue
|
||||||
user_agents_blocked.append(uagent.strip())
|
user_agents_blocked.append(uagent.strip())
|
||||||
if str(self.server.user_agents_blocked) != \
|
if str(self.server.user_agents_blocked) != str(user_agents_blocked):
|
||||||
str(user_agents_blocked):
|
self.server.user_agents_blocked = user_agents_blocked
|
||||||
self.server.user_agents_blocked = \
|
|
||||||
user_agents_blocked
|
|
||||||
user_agents_blocked_str = ''
|
user_agents_blocked_str = ''
|
||||||
for uagent in user_agents_blocked:
|
for uagent in user_agents_blocked:
|
||||||
if user_agents_blocked_str:
|
if user_agents_blocked_str:
|
||||||
|
@ -440,8 +412,7 @@ def _profile_post_dm_instances(base_dir: str, nickname: str, domain: str,
|
||||||
if the .followDMs flag file exists
|
if the .followDMs flag file exists
|
||||||
"""
|
"""
|
||||||
dm_allowed_instances_filename = \
|
dm_allowed_instances_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + '/dmAllowedInstances.txt'
|
||||||
'/dmAllowedInstances.txt'
|
|
||||||
if fields.get('dmAllowedInstances'):
|
if fields.get('dmAllowedInstances'):
|
||||||
try:
|
try:
|
||||||
with open(dm_allowed_instances_filename, 'w+',
|
with open(dm_allowed_instances_filename, 'w+',
|
||||||
|
@ -467,16 +438,14 @@ def _profile_post_import_theme(base_dir: str, nickname: str,
|
||||||
if fields.get('importTheme'):
|
if fields.get('importTheme'):
|
||||||
if not os.path.isdir(base_dir + '/imports'):
|
if not os.path.isdir(base_dir + '/imports'):
|
||||||
os.mkdir(base_dir + '/imports')
|
os.mkdir(base_dir + '/imports')
|
||||||
filename_base = \
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
base_dir + '/imports/newtheme.zip'
|
|
||||||
if os.path.isfile(filename_base):
|
if os.path.isfile(filename_base):
|
||||||
try:
|
try:
|
||||||
os.remove(filename_base)
|
os.remove(filename_base)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: _profile_edit unable to delete ' +
|
print('EX: _profile_edit unable to delete ' +
|
||||||
filename_base)
|
filename_base)
|
||||||
if nickname == admin_nickname or \
|
if nickname == admin_nickname or is_artist(base_dir, nickname):
|
||||||
is_artist(base_dir, nickname):
|
|
||||||
if import_theme(base_dir, filename_base):
|
if import_theme(base_dir, filename_base):
|
||||||
print(nickname + ' uploaded a theme')
|
print(nickname + ' uploaded a theme')
|
||||||
else:
|
else:
|
||||||
|
@ -489,8 +458,7 @@ def _profile_post_import_follows(base_dir: str, nickname: str, domain: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('importFollows'):
|
if fields.get('importFollows'):
|
||||||
filename_base = \
|
filename_base = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + '/import_following.csv'
|
||||||
'/import_following.csv'
|
|
||||||
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:]
|
||||||
|
@ -524,8 +492,7 @@ def _profile_post_auto_cw(base_dir: str, nickname: str, domain: str,
|
||||||
""" HTTP POST autogenerated content warnings
|
""" HTTP POST autogenerated content warnings
|
||||||
"""
|
"""
|
||||||
auto_cw_filename = \
|
auto_cw_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + '/autocw.txt'
|
||||||
'/autocw.txt'
|
|
||||||
if fields.get('autoCW'):
|
if fields.get('autoCW'):
|
||||||
try:
|
try:
|
||||||
with open(auto_cw_filename, 'w+',
|
with open(auto_cw_filename, 'w+',
|
||||||
|
@ -534,8 +501,7 @@ def _profile_post_auto_cw(base_dir: str, nickname: str, domain: str,
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write auto CW ' +
|
print('EX: unable to write auto CW ' +
|
||||||
auto_cw_filename)
|
auto_cw_filename)
|
||||||
self.server.auto_cw_cache[nickname] = \
|
self.server.auto_cw_cache[nickname] = fields['autoCW'].split('\n')
|
||||||
fields['autoCW'].split('\n')
|
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(auto_cw_filename):
|
if os.path.isfile(auto_cw_filename):
|
||||||
try:
|
try:
|
||||||
|
@ -709,16 +675,14 @@ def _profile_post_account_type(path: str, actor_json: {}, fields: {},
|
||||||
""" HTTP POST Changes the type of account Bot/Group/Person
|
""" HTTP POST Changes the type of account Bot/Group/Person
|
||||||
"""
|
"""
|
||||||
if fields.get('isBot'):
|
if fields.get('isBot'):
|
||||||
if fields['isBot'] == 'on' and \
|
if fields['isBot'] == 'on' and actor_json.get('type'):
|
||||||
actor_json.get('type'):
|
|
||||||
if actor_json['type'] != 'Service':
|
if actor_json['type'] != 'Service':
|
||||||
actor_json['type'] = 'Service'
|
actor_json['type'] = 'Service'
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
# this account is a group
|
# this account is a group
|
||||||
if fields.get('isGroup'):
|
if fields.get('isGroup'):
|
||||||
if fields['isGroup'] == 'on' and \
|
if fields['isGroup'] == 'on' and actor_json.get('type'):
|
||||||
actor_json.get('type'):
|
|
||||||
if actor_json['type'] != 'Group':
|
if actor_json['type'] != 'Group':
|
||||||
# only allow admin to create groups
|
# only allow admin to create groups
|
||||||
if path.startswith('/users/' +
|
if path.startswith('/users/' +
|
||||||
|
@ -742,8 +706,7 @@ def _profile_post_notify_reactions(base_dir: str,
|
||||||
""" HTTP POST notify about new Reactions
|
""" HTTP POST notify about new Reactions
|
||||||
"""
|
"""
|
||||||
notify_reactions_filename = \
|
notify_reactions_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + '/.notifyReactions'
|
||||||
'/.notifyReactions'
|
|
||||||
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
|
||||||
|
@ -846,8 +809,7 @@ def _profile_post_hide_follows(base_dir: str, nickname: str, domain: str,
|
||||||
""" HTTP POST hide follows checkbox
|
""" HTTP POST hide follows checkbox
|
||||||
"""
|
"""
|
||||||
hide_follows_filename = \
|
hide_follows_filename = \
|
||||||
acct_dir(base_dir, nickname, domain) + \
|
acct_dir(base_dir, nickname, domain) + '/.hideFollows'
|
||||||
'/.hideFollows'
|
|
||||||
hide_follows = False
|
hide_follows = False
|
||||||
if fields.get('hideFollows'):
|
if fields.get('hideFollows'):
|
||||||
if fields['hideFollows'] == 'on':
|
if fields['hideFollows'] == 'on':
|
||||||
|
@ -884,8 +846,7 @@ def _profile_post_mutuals_replies(account_dir: str, fields: {}) -> None:
|
||||||
if fields.get('repliesFromMutualsOnly'):
|
if fields.get('repliesFromMutualsOnly'):
|
||||||
if fields['repliesFromMutualsOnly'] == 'on':
|
if fields['repliesFromMutualsOnly'] == 'on':
|
||||||
show_replies_mutuals = True
|
show_replies_mutuals = True
|
||||||
show_replies_mutuals_file = \
|
show_replies_mutuals_file = account_dir + '/.repliesFromMutualsOnly'
|
||||||
account_dir + '/.repliesFromMutualsOnly'
|
|
||||||
if os.path.isfile(show_replies_mutuals_file):
|
if os.path.isfile(show_replies_mutuals_file):
|
||||||
if not show_replies_mutuals:
|
if not show_replies_mutuals:
|
||||||
try:
|
try:
|
||||||
|
@ -912,8 +873,7 @@ def _profile_post_only_follower_replies(fields: {},
|
||||||
if fields.get('repliesFromFollowersOnly'):
|
if fields.get('repliesFromFollowersOnly'):
|
||||||
if fields['repliesFromFollowersOnly'] == 'on':
|
if fields['repliesFromFollowersOnly'] == 'on':
|
||||||
show_replies_followers = True
|
show_replies_followers = True
|
||||||
show_replies_followers_file = \
|
show_replies_followers_file = account_dir + '/.repliesFromFollowersOnly'
|
||||||
account_dir + '/.repliesFromFollowersOnly'
|
|
||||||
if os.path.isfile(show_replies_followers_file):
|
if os.path.isfile(show_replies_followers_file):
|
||||||
if not show_replies_followers:
|
if not show_replies_followers:
|
||||||
try:
|
try:
|
||||||
|
@ -1206,14 +1166,12 @@ def _profile_post_remove_custom_font(base_dir: str, nickname: str, domain: str,
|
||||||
curr_theme = get_theme(base_dir)
|
curr_theme = get_theme(base_dir)
|
||||||
if curr_theme:
|
if curr_theme:
|
||||||
self.server.theme_name = curr_theme
|
self.server.theme_name = curr_theme
|
||||||
allow_local_network_access = \
|
allow_local_network_access = self.server.allow_local_network_access
|
||||||
self.server.allow_local_network_access
|
|
||||||
set_theme(base_dir, curr_theme, domain,
|
set_theme(base_dir, curr_theme, domain,
|
||||||
allow_local_network_access,
|
allow_local_network_access,
|
||||||
system_language,
|
system_language,
|
||||||
dyslexic_font, False)
|
dyslexic_font, False)
|
||||||
self.server.text_mode_banner = \
|
self.server.text_mode_banner = get_text_mode_banner(base_dir)
|
||||||
get_text_mode_banner(base_dir)
|
|
||||||
self.server.iconsCache = {}
|
self.server.iconsCache = {}
|
||||||
self.server.fontsCache = {}
|
self.server.fontsCache = {}
|
||||||
self.server.show_publish_as_icon = \
|
self.server.show_publish_as_icon = \
|
||||||
|
@ -1238,8 +1196,7 @@ def _profile_post_keep_dms(base_dir: str,
|
||||||
if fields.get('expiryKeepDMs'):
|
if fields.get('expiryKeepDMs'):
|
||||||
if fields['expiryKeepDMs'] == 'on':
|
if fields['expiryKeepDMs'] == 'on':
|
||||||
expire_keep_dms = True
|
expire_keep_dms = True
|
||||||
curr_keep_dms = \
|
curr_keep_dms = get_post_expiry_keep_dms(base_dir, nickname, domain)
|
||||||
get_post_expiry_keep_dms(base_dir, nickname, domain)
|
|
||||||
if curr_keep_dms != expire_keep_dms:
|
if curr_keep_dms != expire_keep_dms:
|
||||||
set_post_expiry_keep_dms(base_dir, nickname, domain,
|
set_post_expiry_keep_dms(base_dir, nickname, domain,
|
||||||
expire_keep_dms)
|
expire_keep_dms)
|
||||||
|
@ -1290,8 +1247,7 @@ def _profile_post_approve_followers(on_final_welcome_screen: bool,
|
||||||
if fields.get('approveFollowers'):
|
if fields.get('approveFollowers'):
|
||||||
if fields['approveFollowers'] == 'on':
|
if fields['approveFollowers'] == 'on':
|
||||||
approve_followers = True
|
approve_followers = True
|
||||||
if approve_followers != \
|
if approve_followers != actor_json['manuallyApprovesFollowers']:
|
||||||
actor_json['manuallyApprovesFollowers']:
|
|
||||||
actor_json['manuallyApprovesFollowers'] = approve_followers
|
actor_json['manuallyApprovesFollowers'] = approve_followers
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
@ -1304,21 +1260,18 @@ def _profile_post_shared_item_federation_domains(base_dir: str, fields: {},
|
||||||
# shared item federation domains
|
# shared item federation domains
|
||||||
si_domain_updated = False
|
si_domain_updated = False
|
||||||
fed_domains_variable = "sharedItemsFederatedDomains"
|
fed_domains_variable = "sharedItemsFederatedDomains"
|
||||||
fed_domains_str = \
|
fed_domains_str = get_config_param(base_dir, fed_domains_variable)
|
||||||
get_config_param(base_dir, fed_domains_variable)
|
|
||||||
if not fed_domains_str:
|
if not fed_domains_str:
|
||||||
fed_domains_str = ''
|
fed_domains_str = ''
|
||||||
shared_items_form_str = ''
|
shared_items_form_str = ''
|
||||||
if fields.get('shareDomainList'):
|
if fields.get('shareDomainList'):
|
||||||
shared_it_list = fed_domains_str.split(',')
|
shared_it_list = fed_domains_str.split(',')
|
||||||
for shared_federated_domain in shared_it_list:
|
for shared_federated_domain in shared_it_list:
|
||||||
shared_items_form_str += \
|
shared_items_form_str += shared_federated_domain.strip() + '\n'
|
||||||
shared_federated_domain.strip() + '\n'
|
|
||||||
|
|
||||||
share_domain_list = fields['shareDomainList']
|
share_domain_list = fields['shareDomainList']
|
||||||
if share_domain_list != shared_items_form_str:
|
if share_domain_list != shared_items_form_str:
|
||||||
shared_items_form_str2 = \
|
shared_items_form_str2 = share_domain_list.replace('\n', ',')
|
||||||
share_domain_list.replace('\n', ',')
|
|
||||||
shared_items_field = "sharedItemsFederatedDomains"
|
shared_items_field = "sharedItemsFederatedDomains"
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
shared_items_field,
|
shared_items_field,
|
||||||
|
@ -1326,8 +1279,7 @@ def _profile_post_shared_item_federation_domains(base_dir: str, fields: {},
|
||||||
si_domain_updated = True
|
si_domain_updated = True
|
||||||
else:
|
else:
|
||||||
if fed_domains_str:
|
if fed_domains_str:
|
||||||
shared_items_field = \
|
shared_items_field = "sharedItemsFederatedDomains"
|
||||||
"sharedItemsFederatedDomains"
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
shared_items_field, '')
|
shared_items_field, '')
|
||||||
si_domain_updated = True
|
si_domain_updated = True
|
||||||
|
@ -1338,10 +1290,8 @@ def _profile_post_shared_item_federation_domains(base_dir: str, fields: {},
|
||||||
domain_full = self.server.domain_full
|
domain_full = self.server.domain_full
|
||||||
base_dir = self.server.base_dir
|
base_dir = self.server.base_dir
|
||||||
self.server.shared_item_federation_tokens = \
|
self.server.shared_item_federation_tokens = \
|
||||||
merge_shared_item_tokens(base_dir,
|
merge_shared_item_tokens(base_dir, domain_full,
|
||||||
domain_full,
|
si_domains, si_tokens)
|
||||||
si_domains,
|
|
||||||
si_tokens)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_broch_mode(base_dir: str, domain_full: str,
|
def _profile_post_broch_mode(base_dir: str, domain_full: str,
|
||||||
|
@ -1380,8 +1330,7 @@ def _profile_post_show_nodeinfo_version(base_dir: str, fields: {},
|
||||||
if fields.get('showNodeInfoVersion'):
|
if fields.get('showNodeInfoVersion'):
|
||||||
if fields['showNodeInfoVersion'] == 'on':
|
if fields['showNodeInfoVersion'] == 'on':
|
||||||
show_node_info_version = True
|
show_node_info_version = True
|
||||||
self.server.show_node_info_version = \
|
self.server.show_node_info_version = show_node_info_version
|
||||||
show_node_info_version
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
"showNodeInfoVersion",
|
"showNodeInfoVersion",
|
||||||
show_node_info_version)
|
show_node_info_version)
|
||||||
|
@ -1394,8 +1343,7 @@ def _profile_post_show_nodeinfo(base_dir: str, fields: {}, self) -> None:
|
||||||
if fields.get('showNodeInfoAccounts'):
|
if fields.get('showNodeInfoAccounts'):
|
||||||
if fields['showNodeInfoAccounts'] == 'on':
|
if fields['showNodeInfoAccounts'] == 'on':
|
||||||
show_node_info_accounts = True
|
show_node_info_accounts = True
|
||||||
self.server.show_node_info_accounts = \
|
self.server.show_node_info_accounts = show_node_info_accounts
|
||||||
show_node_info_accounts
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
"showNodeInfoAccounts",
|
"showNodeInfoAccounts",
|
||||||
show_node_info_accounts)
|
show_node_info_accounts)
|
||||||
|
@ -1464,8 +1412,7 @@ def _profile_post_alsoknownas(actor_json: {}, fields: {},
|
||||||
if ';' in fields['alsoKnownAs']:
|
if ';' in fields['alsoKnownAs']:
|
||||||
fields['alsoKnownAs'] = \
|
fields['alsoKnownAs'] = \
|
||||||
fields['alsoKnownAs'].replace(';', ',')
|
fields['alsoKnownAs'].replace(';', ',')
|
||||||
new_also_known_as = \
|
new_also_known_as = fields['alsoKnownAs'].split(',')
|
||||||
fields['alsoKnownAs'].split(',')
|
|
||||||
also_known_as = []
|
also_known_as = []
|
||||||
for alt_actor in new_also_known_as:
|
for alt_actor in new_also_known_as:
|
||||||
alt_actor = alt_actor.strip()
|
alt_actor = alt_actor.strip()
|
||||||
|
@ -1487,10 +1434,8 @@ def _profile_post_featured_hashtags(actor_json: {}, fields: {},
|
||||||
"""
|
"""
|
||||||
featured_hashtags = get_featured_hashtags(actor_json)
|
featured_hashtags = get_featured_hashtags(actor_json)
|
||||||
if fields.get('featuredHashtags'):
|
if fields.get('featuredHashtags'):
|
||||||
fields['featuredHashtags'] = \
|
fields['featuredHashtags'] = remove_html(fields['featuredHashtags'])
|
||||||
remove_html(fields['featuredHashtags'])
|
if featured_hashtags != fields['featuredHashtags']:
|
||||||
if featured_hashtags != \
|
|
||||||
fields['featuredHashtags']:
|
|
||||||
set_featured_hashtags(actor_json,
|
set_featured_hashtags(actor_json,
|
||||||
fields['featuredHashtags'])
|
fields['featuredHashtags'])
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
|
@ -1507,10 +1452,8 @@ def _profile_post_occupation(actor_json: {}, fields: {},
|
||||||
"""
|
"""
|
||||||
occupation_name = get_occupation_name(actor_json)
|
occupation_name = get_occupation_name(actor_json)
|
||||||
if fields.get('occupationName'):
|
if fields.get('occupationName'):
|
||||||
fields['occupationName'] = \
|
fields['occupationName'] = remove_html(fields['occupationName'])
|
||||||
remove_html(fields['occupationName'])
|
if occupation_name != fields['occupationName']:
|
||||||
if occupation_name != \
|
|
||||||
fields['occupationName']:
|
|
||||||
set_occupation_name(actor_json,
|
set_occupation_name(actor_json,
|
||||||
fields['occupationName'])
|
fields['occupationName'])
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
|
@ -1530,8 +1473,7 @@ def _profile_post_moved(actor_json: {}, fields: {},
|
||||||
if actor_json.get('movedTo'):
|
if actor_json.get('movedTo'):
|
||||||
moved_to = actor_json['movedTo']
|
moved_to = actor_json['movedTo']
|
||||||
if fields.get('movedTo'):
|
if fields.get('movedTo'):
|
||||||
if fields['movedTo'] != moved_to and \
|
if fields['movedTo'] != moved_to and resembles_url(fields['movedTo']):
|
||||||
resembles_url(fields['movedTo']):
|
|
||||||
actor_json['movedTo'] = fields['movedTo']
|
actor_json['movedTo'] = fields['movedTo']
|
||||||
send_move_activity = True
|
send_move_activity = True
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
|
@ -1657,9 +1599,7 @@ def _profile_post_ntfy_topic(base_dir: str, nickname: str, domain: str,
|
||||||
""" HTTP POST change ntfy topic
|
""" HTTP POST change ntfy topic
|
||||||
"""
|
"""
|
||||||
if fields.get('ntfyTopic'):
|
if fields.get('ntfyTopic'):
|
||||||
ntfy_topic_file = \
|
ntfy_topic_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_topic'
|
||||||
base_dir + '/accounts/' + \
|
|
||||||
nickname + '@' + domain + '/.ntfy_topic'
|
|
||||||
try:
|
try:
|
||||||
with open(ntfy_topic_file, 'w+',
|
with open(ntfy_topic_file, 'w+',
|
||||||
encoding='utf-8') as fp_ntfy:
|
encoding='utf-8') as fp_ntfy:
|
||||||
|
@ -1674,9 +1614,7 @@ def _profile_post_ntfy_url(base_dir: str, nickname: str, domain: str,
|
||||||
""" HTTP POST change ntfy url
|
""" HTTP POST change ntfy url
|
||||||
"""
|
"""
|
||||||
if fields.get('ntfyUrl'):
|
if fields.get('ntfyUrl'):
|
||||||
ntfy_url_file = \
|
ntfy_url_file = acct_dir(base_dir, nickname, domain) + '/.ntfy_url'
|
||||||
base_dir + '/accounts/' + \
|
|
||||||
nickname + '@' + domain + '/.ntfy_url'
|
|
||||||
try:
|
try:
|
||||||
with open(ntfy_url_file, 'w+',
|
with open(ntfy_url_file, 'w+',
|
||||||
encoding='utf-8') as fp_ntfy:
|
encoding='utf-8') as fp_ntfy:
|
||||||
|
@ -1747,8 +1685,7 @@ def _profile_post_birthday(fields: {}, actor_json: {},
|
||||||
if fields.get('birthDate'):
|
if fields.get('birthDate'):
|
||||||
if fields['birthDate'] != birth_date:
|
if fields['birthDate'] != birth_date:
|
||||||
new_birth_date = fields['birthDate']
|
new_birth_date = fields['birthDate']
|
||||||
if '-' in new_birth_date and \
|
if '-' in new_birth_date and len(new_birth_date.split('-')) == 3:
|
||||||
len(new_birth_date.split('-')) == 3:
|
|
||||||
# set birth date
|
# set birth date
|
||||||
actor_json['vcard:bday'] = new_birth_date
|
actor_json['vcard:bday'] = new_birth_date
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
|
@ -1764,13 +1701,10 @@ def _profile_post_max_preview(base_dir: str, nickname: str, domain: str,
|
||||||
fields: {}) -> None:
|
fields: {}) -> None:
|
||||||
""" HTTP POST set maximum preview posts on profile screen
|
""" HTTP POST set maximum preview posts on profile screen
|
||||||
"""
|
"""
|
||||||
max_profile_posts = \
|
max_profile_posts = get_max_profile_posts(base_dir, nickname, domain, 20)
|
||||||
get_max_profile_posts(base_dir, nickname, domain, 20)
|
|
||||||
if fields.get('maxRecentProfilePosts'):
|
if fields.get('maxRecentProfilePosts'):
|
||||||
if fields['maxRecentProfilePosts'] != \
|
if fields['maxRecentProfilePosts'] != str(max_profile_posts):
|
||||||
str(max_profile_posts):
|
max_profile_posts = fields['maxRecentProfilePosts']
|
||||||
max_profile_posts = \
|
|
||||||
fields['maxRecentProfilePosts']
|
|
||||||
set_max_profile_posts(base_dir, nickname, domain,
|
set_max_profile_posts(base_dir, nickname, domain,
|
||||||
max_profile_posts)
|
max_profile_posts)
|
||||||
else:
|
else:
|
||||||
|
@ -1781,13 +1715,10 @@ def _profile_post_expiry(base_dir: str, nickname: str, domain: str,
|
||||||
fields: {}, actor_changed: bool) -> bool:
|
fields: {}, actor_changed: bool) -> bool:
|
||||||
""" HTTP POST set post expiry period in days
|
""" HTTP POST set post expiry period in days
|
||||||
"""
|
"""
|
||||||
post_expiry_period_days = \
|
post_expiry_period_days = get_post_expiry_days(base_dir, nickname, domain)
|
||||||
get_post_expiry_days(base_dir, nickname, domain)
|
|
||||||
if fields.get('postExpiryPeriod'):
|
if fields.get('postExpiryPeriod'):
|
||||||
if fields['postExpiryPeriod'] != \
|
if fields['postExpiryPeriod'] != str(post_expiry_period_days):
|
||||||
str(post_expiry_period_days):
|
post_expiry_period_days = fields['postExpiryPeriod']
|
||||||
post_expiry_period_days = \
|
|
||||||
fields['postExpiryPeriod']
|
|
||||||
set_post_expiry_days(base_dir, nickname, domain,
|
set_post_expiry_days(base_dir, nickname, domain,
|
||||||
post_expiry_period_days)
|
post_expiry_period_days)
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
|
@ -1808,8 +1739,7 @@ def _profile_post_time_zone(base_dir: str, nickname: str, domain: str,
|
||||||
set_account_timezone(base_dir,
|
set_account_timezone(base_dir,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
fields['timeZone'])
|
fields['timeZone'])
|
||||||
self.server.account_timezone[nickname] = \
|
self.server.account_timezone[nickname] = fields['timeZone']
|
||||||
fields['timeZone']
|
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
else:
|
else:
|
||||||
if timezone:
|
if timezone:
|
||||||
|
@ -1936,8 +1866,7 @@ def _profile_post_memorial_accounts(base_dir: str, domain: str,
|
||||||
"""
|
"""
|
||||||
curr_memorial = get_memorials(base_dir)
|
curr_memorial = get_memorials(base_dir)
|
||||||
if fields.get('memorialAccounts'):
|
if fields.get('memorialAccounts'):
|
||||||
if fields['memorialAccounts'] != \
|
if fields['memorialAccounts'] != curr_memorial:
|
||||||
curr_memorial:
|
|
||||||
set_memorials(base_dir, domain,
|
set_memorials(base_dir, domain,
|
||||||
fields['memorialAccounts'])
|
fields['memorialAccounts'])
|
||||||
update_memorial_flags(base_dir,
|
update_memorial_flags(base_dir,
|
||||||
|
@ -1954,8 +1883,7 @@ def _profile_post_instance_desc(base_dir: str, fields: {}) -> None:
|
||||||
curr_instance_description = \
|
curr_instance_description = \
|
||||||
get_config_param(base_dir, 'instanceDescription')
|
get_config_param(base_dir, 'instanceDescription')
|
||||||
if fields.get('instanceDescription'):
|
if fields.get('instanceDescription'):
|
||||||
if fields['instanceDescription'] != \
|
if fields['instanceDescription'] != curr_instance_description:
|
||||||
curr_instance_description:
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
'instanceDescription',
|
'instanceDescription',
|
||||||
fields['instanceDescription'])
|
fields['instanceDescription'])
|
||||||
|
@ -1969,8 +1897,7 @@ def _profile_post_instance_short_desc(base_dir: str, fields: {}) -> None:
|
||||||
""" HTTP POST change instance short description
|
""" HTTP POST change instance short description
|
||||||
"""
|
"""
|
||||||
curr_instance_description_short = \
|
curr_instance_description_short = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'instanceDescriptionShort')
|
||||||
'instanceDescriptionShort')
|
|
||||||
if fields.get('instanceDescriptionShort'):
|
if fields.get('instanceDescriptionShort'):
|
||||||
if fields['instanceDescriptionShort'] != \
|
if fields['instanceDescriptionShort'] != \
|
||||||
curr_instance_description_short:
|
curr_instance_description_short:
|
||||||
|
@ -1987,24 +1914,17 @@ def _profile_post_content_license(base_dir: str, fields: {}, self) -> None:
|
||||||
""" HTTP POST change instance content license
|
""" HTTP POST change instance content license
|
||||||
"""
|
"""
|
||||||
if fields.get('contentLicenseUrl'):
|
if fields.get('contentLicenseUrl'):
|
||||||
if fields['contentLicenseUrl'] != \
|
if fields['contentLicenseUrl'] != self.server.content_license_url:
|
||||||
self.server.content_license_url:
|
|
||||||
license_str = fields['contentLicenseUrl']
|
license_str = fields['contentLicenseUrl']
|
||||||
if '://' not in license_str:
|
if '://' not in license_str:
|
||||||
license_str = \
|
license_str = license_link_from_name(license_str)
|
||||||
license_link_from_name(license_str)
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
'contentLicenseUrl',
|
'contentLicenseUrl',
|
||||||
license_str)
|
license_str)
|
||||||
self.server.content_license_url = \
|
self.server.content_license_url = license_str
|
||||||
license_str
|
|
||||||
else:
|
else:
|
||||||
license_str = \
|
license_str = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||||
'https://creativecommons.org/' + \
|
set_config_param(base_dir, 'contentLicenseUrl', license_str)
|
||||||
'licenses/by-nc/4.0'
|
|
||||||
set_config_param(base_dir,
|
|
||||||
'contentLicenseUrl',
|
|
||||||
license_str)
|
|
||||||
self.server.content_license_url = license_str
|
self.server.content_license_url = license_str
|
||||||
|
|
||||||
|
|
||||||
|
@ -2012,11 +1932,9 @@ def _profile_post_libretranslate_api_key(base_dir: str, fields: {}) -> None:
|
||||||
""" HTTP POST libretranslate API Key
|
""" HTTP POST libretranslate API Key
|
||||||
"""
|
"""
|
||||||
curr_libretranslate_api_key = \
|
curr_libretranslate_api_key = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'libretranslateApiKey')
|
||||||
'libretranslateApiKey')
|
|
||||||
if fields.get('libretranslateApiKey'):
|
if fields.get('libretranslateApiKey'):
|
||||||
if fields['libretranslateApiKey'] != \
|
if fields['libretranslateApiKey'] != curr_libretranslate_api_key:
|
||||||
curr_libretranslate_api_key:
|
|
||||||
lt_api_key = fields['libretranslateApiKey']
|
lt_api_key = fields['libretranslateApiKey']
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
'libretranslateApiKey',
|
'libretranslateApiKey',
|
||||||
|
@ -2046,17 +1964,12 @@ def _profile_post_registrations_remaining(base_dir: str, fields: {}) -> None:
|
||||||
def _profile_post_libretranslate_url(base_dir: str, fields: {}) -> None:
|
def _profile_post_libretranslate_url(base_dir: str, fields: {}) -> None:
|
||||||
""" HTTP POST libretranslate URL
|
""" HTTP POST libretranslate URL
|
||||||
"""
|
"""
|
||||||
curr_libretranslate_url = \
|
curr_libretranslate_url = get_config_param(base_dir, 'libretranslateUrl')
|
||||||
get_config_param(base_dir,
|
|
||||||
'libretranslateUrl')
|
|
||||||
if fields.get('libretranslateUrl'):
|
if fields.get('libretranslateUrl'):
|
||||||
if fields['libretranslateUrl'] != \
|
if fields['libretranslateUrl'] != curr_libretranslate_url:
|
||||||
curr_libretranslate_url:
|
|
||||||
lt_url = fields['libretranslateUrl']
|
lt_url = fields['libretranslateUrl']
|
||||||
if resembles_url(lt_url):
|
if resembles_url(lt_url):
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir, 'libretranslateUrl', lt_url)
|
||||||
'libretranslateUrl',
|
|
||||||
lt_url)
|
|
||||||
else:
|
else:
|
||||||
if curr_libretranslate_url:
|
if curr_libretranslate_url:
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
|
@ -2068,19 +1981,15 @@ def _profile_post_replies_unlisted(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
pub_replies_unlisted = False
|
pub_replies_unlisted = False
|
||||||
if self.server.public_replies_unlisted or \
|
if self.server.public_replies_unlisted or \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, "publicRepliesUnlisted") is True:
|
||||||
"publicRepliesUnlisted") is True:
|
|
||||||
pub_replies_unlisted = True
|
pub_replies_unlisted = True
|
||||||
if fields.get('publicRepliesUnlisted'):
|
if fields.get('publicRepliesUnlisted'):
|
||||||
if fields['publicRepliesUnlisted'] != \
|
if fields['publicRepliesUnlisted'] != pub_replies_unlisted:
|
||||||
pub_replies_unlisted:
|
pub_replies_unlisted = fields['publicRepliesUnlisted']
|
||||||
pub_replies_unlisted = \
|
|
||||||
fields['publicRepliesUnlisted']
|
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
'publicRepliesUnlisted',
|
'publicRepliesUnlisted',
|
||||||
True)
|
True)
|
||||||
self.server.public_replies_unlisted = \
|
self.server.public_replies_unlisted = pub_replies_unlisted
|
||||||
pub_replies_unlisted
|
|
||||||
else:
|
else:
|
||||||
if pub_replies_unlisted:
|
if pub_replies_unlisted:
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
|
@ -2094,8 +2003,7 @@ def _profile_post_registrations_open(base_dir: str, fields: {}, self) -> None:
|
||||||
"""
|
"""
|
||||||
registrations_open = False
|
registrations_open = False
|
||||||
if self.server.registration or \
|
if self.server.registration or \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, "registration") == 'open':
|
||||||
"registration") == 'open':
|
|
||||||
registrations_open = True
|
registrations_open = True
|
||||||
if fields.get('regOpen'):
|
if fields.get('regOpen'):
|
||||||
if fields['regOpen'] != registrations_open:
|
if fields['regOpen'] != registrations_open:
|
||||||
|
@ -2103,8 +2011,7 @@ def _profile_post_registrations_open(base_dir: str, fields: {}, self) -> None:
|
||||||
set_config_param(base_dir, 'registration',
|
set_config_param(base_dir, 'registration',
|
||||||
'open')
|
'open')
|
||||||
remaining = \
|
remaining = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'registrationsRemaining')
|
||||||
'registrationsRemaining')
|
|
||||||
if not remaining:
|
if not remaining:
|
||||||
set_config_param(base_dir,
|
set_config_param(base_dir,
|
||||||
'registrationsRemaining',
|
'registrationsRemaining',
|
||||||
|
@ -2122,8 +2029,7 @@ def _profile_post_submit_button(base_dir: str, fields: {}) -> None:
|
||||||
"""
|
"""
|
||||||
curr_custom_submit_text = get_config_param(base_dir, 'customSubmitText')
|
curr_custom_submit_text = get_config_param(base_dir, 'customSubmitText')
|
||||||
if fields.get('customSubmitText'):
|
if fields.get('customSubmitText'):
|
||||||
if fields['customSubmitText'] != \
|
if fields['customSubmitText'] != curr_custom_submit_text:
|
||||||
curr_custom_submit_text:
|
|
||||||
custom_text = fields['customSubmitText']
|
custom_text = fields['customSubmitText']
|
||||||
set_config_param(base_dir, 'customSubmitText', custom_text)
|
set_config_param(base_dir, 'customSubmitText', custom_text)
|
||||||
else:
|
else:
|
||||||
|
@ -2136,21 +2042,17 @@ def _profile_post_twitter_alt_domain(base_dir: str, fields: {},
|
||||||
""" HTTP POST change twitter alternate domain
|
""" HTTP POST change twitter alternate domain
|
||||||
"""
|
"""
|
||||||
if fields.get('twitterdomain'):
|
if fields.get('twitterdomain'):
|
||||||
curr_twitter_domain = \
|
curr_twitter_domain = self.server.twitter_replacement_domain
|
||||||
self.server.twitter_replacement_domain
|
|
||||||
if fields['twitterdomain'] != curr_twitter_domain:
|
if fields['twitterdomain'] != curr_twitter_domain:
|
||||||
new_twitter_domain = fields['twitterdomain']
|
new_twitter_domain = fields['twitterdomain']
|
||||||
if '://' in new_twitter_domain:
|
if '://' in new_twitter_domain:
|
||||||
new_twitter_domain = \
|
new_twitter_domain = new_twitter_domain.split('://')[1]
|
||||||
new_twitter_domain.split('://')[1]
|
|
||||||
if '/' in new_twitter_domain:
|
if '/' in new_twitter_domain:
|
||||||
new_twitter_domain = \
|
new_twitter_domain = new_twitter_domain.split('/')[0]
|
||||||
new_twitter_domain.split('/')[0]
|
|
||||||
if '.' in new_twitter_domain:
|
if '.' in new_twitter_domain:
|
||||||
set_config_param(base_dir, 'twitterdomain',
|
set_config_param(base_dir, 'twitterdomain',
|
||||||
new_twitter_domain)
|
new_twitter_domain)
|
||||||
self.server.twitter_replacement_domain = \
|
self.server.twitter_replacement_domain = new_twitter_domain
|
||||||
new_twitter_domain
|
|
||||||
else:
|
else:
|
||||||
set_config_param(base_dir, 'twitterdomain', '')
|
set_config_param(base_dir, 'twitterdomain', '')
|
||||||
self.server.twitter_replacement_domain = None
|
self.server.twitter_replacement_domain = None
|
||||||
|
@ -2165,15 +2067,13 @@ def _profile_post_youtube_alt_domain(base_dir: str, fields: {},
|
||||||
if fields['ytdomain'] != curr_yt_domain:
|
if fields['ytdomain'] != curr_yt_domain:
|
||||||
new_yt_domain = fields['ytdomain']
|
new_yt_domain = fields['ytdomain']
|
||||||
if '://' in new_yt_domain:
|
if '://' in new_yt_domain:
|
||||||
new_yt_domain = \
|
new_yt_domain = new_yt_domain.split('://')[1]
|
||||||
new_yt_domain.split('://')[1]
|
|
||||||
if '/' in new_yt_domain:
|
if '/' in new_yt_domain:
|
||||||
new_yt_domain = new_yt_domain.split('/')[0]
|
new_yt_domain = new_yt_domain.split('/')[0]
|
||||||
if '.' in new_yt_domain:
|
if '.' in new_yt_domain:
|
||||||
set_config_param(base_dir, 'youtubedomain',
|
set_config_param(base_dir, 'youtubedomain',
|
||||||
new_yt_domain)
|
new_yt_domain)
|
||||||
self.server.yt_replace_domain = \
|
self.server.yt_replace_domain = new_yt_domain
|
||||||
new_yt_domain
|
|
||||||
else:
|
else:
|
||||||
set_config_param(base_dir, 'youtubedomain', '')
|
set_config_param(base_dir, 'youtubedomain', '')
|
||||||
self.server.yt_replace_domain = None
|
self.server.yt_replace_domain = None
|
||||||
|
@ -2183,8 +2083,7 @@ def _profile_post_instance_title(base_dir: str, fields: {}) -> None:
|
||||||
""" HTTP POST change instance title
|
""" HTTP POST change instance title
|
||||||
"""
|
"""
|
||||||
if fields.get('instanceTitle'):
|
if fields.get('instanceTitle'):
|
||||||
curr_instance_title = \
|
curr_instance_title = get_config_param(base_dir, 'instanceTitle')
|
||||||
get_config_param(base_dir, 'instanceTitle')
|
|
||||||
if fields['instanceTitle'] != curr_instance_title:
|
if fields['instanceTitle'] != curr_instance_title:
|
||||||
set_config_param(base_dir, 'instanceTitle',
|
set_config_param(base_dir, 'instanceTitle',
|
||||||
fields['instanceTitle'])
|
fields['instanceTitle'])
|
||||||
|
@ -2277,41 +2176,30 @@ def _profile_post_theme_change(base_dir: str, nickname: str,
|
||||||
dyslexic_font: bool, self) -> None:
|
dyslexic_font: bool, self) -> None:
|
||||||
""" HTTP POST change the theme from edit profile screen
|
""" HTTP POST change the theme from edit profile screen
|
||||||
"""
|
"""
|
||||||
if nickname == admin_nickname or \
|
if nickname == admin_nickname or is_artist(base_dir, nickname):
|
||||||
is_artist(base_dir, nickname):
|
|
||||||
if fields.get('themeDropdown'):
|
if fields.get('themeDropdown'):
|
||||||
if theme_name != \
|
if theme_name != fields['themeDropdown']:
|
||||||
fields['themeDropdown']:
|
theme_name = fields['themeDropdown']
|
||||||
theme_name = \
|
|
||||||
fields['themeDropdown']
|
|
||||||
set_theme(base_dir, theme_name,
|
set_theme(base_dir, theme_name,
|
||||||
domain, allow_local_network_access,
|
domain, allow_local_network_access,
|
||||||
system_language,
|
system_language,
|
||||||
dyslexic_font, True)
|
dyslexic_font, True)
|
||||||
self.server.text_mode_banner = \
|
self.server.text_mode_banner = get_text_mode_banner(base_dir)
|
||||||
get_text_mode_banner(base_dir)
|
|
||||||
self.server.iconsCache = {}
|
self.server.iconsCache = {}
|
||||||
self.server.fontsCache = {}
|
self.server.fontsCache = {}
|
||||||
self.server.css_cache = {}
|
self.server.css_cache = {}
|
||||||
self.server.show_publish_as_icon = \
|
self.server.show_publish_as_icon = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'showPublishAsIcon')
|
||||||
'showPublishAsIcon')
|
|
||||||
self.server.full_width_tl_button_header = \
|
self.server.full_width_tl_button_header = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'fullWidthTlButtonHeader')
|
||||||
'fullWidthTlButtonHeader')
|
|
||||||
self.server.icons_as_buttons = \
|
self.server.icons_as_buttons = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'iconsAsButtons')
|
||||||
'iconsAsButtons')
|
|
||||||
self.server.rss_icon_at_top = \
|
self.server.rss_icon_at_top = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'rssIconAtTop')
|
||||||
'rssIconAtTop')
|
|
||||||
self.server.publish_button_at_top = \
|
self.server.publish_button_at_top = \
|
||||||
get_config_param(base_dir,
|
get_config_param(base_dir, 'publishButtonAtTop')
|
||||||
'publishButtonAtTop')
|
set_news_avatar(base_dir, fields['themeDropdown'],
|
||||||
set_news_avatar(base_dir,
|
http_prefix, domain, domain_full)
|
||||||
fields['themeDropdown'],
|
|
||||||
http_prefix,
|
|
||||||
domain, domain_full)
|
|
||||||
|
|
||||||
|
|
||||||
def _profile_post_change_displayed_name(base_dir: str,
|
def _profile_post_change_displayed_name(base_dir: str,
|
||||||
|
@ -2326,12 +2214,9 @@ def _profile_post_change_displayed_name(base_dir: str,
|
||||||
"""
|
"""
|
||||||
if fields.get('displayNickname'):
|
if fields.get('displayNickname'):
|
||||||
if fields['displayNickname'] != actor_json['name']:
|
if fields['displayNickname'] != actor_json['name']:
|
||||||
display_name = \
|
display_name = remove_html(fields['displayNickname'])
|
||||||
remove_html(fields['displayNickname'])
|
if not is_filtered(base_dir, nickname, domain,
|
||||||
if not is_filtered(base_dir,
|
display_name, system_language):
|
||||||
nickname, domain,
|
|
||||||
display_name,
|
|
||||||
system_language):
|
|
||||||
actor_json['name'] = display_name
|
actor_json['name'] = display_name
|
||||||
else:
|
else:
|
||||||
actor_json['name'] = nickname
|
actor_json['name'] = nickname
|
||||||
|
@ -2349,8 +2234,7 @@ def _profile_post_change_city(base_dir: str, nickname: str, domain: str,
|
||||||
""" HTTP POST change city
|
""" HTTP POST change city
|
||||||
"""
|
"""
|
||||||
if fields.get('cityDropdown'):
|
if fields.get('cityDropdown'):
|
||||||
city_filename = \
|
city_filename = acct_dir(base_dir, nickname, domain) + '/city.txt'
|
||||||
acct_dir(base_dir, nickname, domain) + '/city.txt'
|
|
||||||
try:
|
try:
|
||||||
with open(city_filename, 'w+',
|
with open(city_filename, 'w+',
|
||||||
encoding='utf-8') as fp_city:
|
encoding='utf-8') as fp_city:
|
||||||
|
@ -2374,10 +2258,8 @@ def _profile_post_change_password(base_dir: str, nickname: str,
|
||||||
fields: {}) -> None:
|
fields: {}) -> None:
|
||||||
""" HTTP POST change password
|
""" HTTP POST change password
|
||||||
"""
|
"""
|
||||||
if fields.get('password') and \
|
if fields.get('password') and fields.get('passwordconfirm'):
|
||||||
fields.get('passwordconfirm'):
|
fields['password'] = remove_eol(fields['password']).strip()
|
||||||
fields['password'] = \
|
|
||||||
remove_eol(fields['password']).strip()
|
|
||||||
fields['passwordconfirm'] = \
|
fields['passwordconfirm'] = \
|
||||||
remove_eol(fields['passwordconfirm']).strip()
|
remove_eol(fields['passwordconfirm']).strip()
|
||||||
if valid_password(fields['password']) and \
|
if valid_password(fields['password']) and \
|
||||||
|
@ -2398,8 +2280,7 @@ def _profile_post_skill_level(actor_json: {},
|
||||||
skill_ctr = 1
|
skill_ctr = 1
|
||||||
actor_skills_ctr = no_of_actor_skills(actor_json)
|
actor_skills_ctr = no_of_actor_skills(actor_json)
|
||||||
while skill_ctr < 10:
|
while skill_ctr < 10:
|
||||||
skill_name = \
|
skill_name = fields.get('skillName' + str(skill_ctr))
|
||||||
fields.get('skillName' + str(skill_ctr))
|
|
||||||
if not skill_name:
|
if not skill_name:
|
||||||
skill_ctr += 1
|
skill_ctr += 1
|
||||||
continue
|
continue
|
||||||
|
@ -2407,8 +2288,7 @@ def _profile_post_skill_level(actor_json: {},
|
||||||
system_language):
|
system_language):
|
||||||
skill_ctr += 1
|
skill_ctr += 1
|
||||||
continue
|
continue
|
||||||
skill_value = \
|
skill_value = fields.get('skillValue' + str(skill_ctr))
|
||||||
fields.get('skillValue' + str(skill_ctr))
|
|
||||||
if not skill_value:
|
if not skill_value:
|
||||||
skill_ctr += 1
|
skill_ctr += 1
|
||||||
continue
|
continue
|
||||||
|
@ -2425,8 +2305,7 @@ def _profile_post_skill_level(actor_json: {},
|
||||||
set_hashtag_category(base_dir, skill_name,
|
set_hashtag_category(base_dir, skill_name,
|
||||||
skills_str, False)
|
skills_str, False)
|
||||||
skill_ctr += 1
|
skill_ctr += 1
|
||||||
if no_of_actor_skills(actor_json) != \
|
if no_of_actor_skills(actor_json) != actor_skills_ctr:
|
||||||
actor_skills_ctr:
|
|
||||||
actor_changed = True
|
actor_changed = True
|
||||||
return actor_changed
|
return actor_changed
|
||||||
|
|
||||||
|
@ -2439,8 +2318,7 @@ def _profile_post_avatar_image_ext(profile_media_types_uploaded: {},
|
||||||
for m_type, last_part in uploads:
|
for m_type, last_part in uploads:
|
||||||
rep_str = '/' + last_part
|
rep_str = '/' + last_part
|
||||||
if m_type == 'avatar':
|
if m_type == 'avatar':
|
||||||
url_str = \
|
url_str = get_url_from_post(actor_json['icon']['url'])
|
||||||
get_url_from_post(actor_json['icon']['url'])
|
|
||||||
actor_url = remove_html(url_str)
|
actor_url = remove_html(url_str)
|
||||||
last_part_of_url = actor_url.split('/')[-1]
|
last_part_of_url = actor_url.split('/')[-1]
|
||||||
srch_str = '/' + last_part_of_url
|
srch_str = '/' + last_part_of_url
|
||||||
|
@ -2451,23 +2329,18 @@ def _profile_post_avatar_image_ext(profile_media_types_uploaded: {},
|
||||||
img_ext = actor_url.split('.')[-1]
|
img_ext = actor_url.split('.')[-1]
|
||||||
if img_ext == 'jpg':
|
if img_ext == 'jpg':
|
||||||
img_ext = 'jpeg'
|
img_ext = 'jpeg'
|
||||||
actor_json['icon']['mediaType'] = \
|
actor_json['icon']['mediaType'] = 'image/' + img_ext
|
||||||
'image/' + img_ext
|
|
||||||
elif m_type == 'image':
|
elif m_type == 'image':
|
||||||
url_str = \
|
url_str = get_url_from_post(actor_json['image']['url'])
|
||||||
get_url_from_post(actor_json['image']['url'])
|
im_url = remove_html(url_str)
|
||||||
im_url = \
|
|
||||||
remove_html(url_str)
|
|
||||||
last_part_of_url = im_url.split('/')[-1]
|
last_part_of_url = im_url.split('/')[-1]
|
||||||
srch_str = '/' + last_part_of_url
|
srch_str = '/' + last_part_of_url
|
||||||
actor_json['image']['url'] = \
|
actor_json['image']['url'] = im_url.replace(srch_str, rep_str)
|
||||||
im_url.replace(srch_str, rep_str)
|
|
||||||
if '.' in im_url:
|
if '.' in im_url:
|
||||||
img_ext = im_url.split('.')[-1]
|
img_ext = im_url.split('.')[-1]
|
||||||
if img_ext == 'jpg':
|
if img_ext == 'jpg':
|
||||||
img_ext = 'jpeg'
|
img_ext = 'jpeg'
|
||||||
actor_json['image']['mediaType'] = \
|
actor_json['image']['mediaType'] = 'image/' + img_ext
|
||||||
'image/' + img_ext
|
|
||||||
|
|
||||||
|
|
||||||
def profile_edit(self, calling_domain: str, cookie: str,
|
def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
|
@ -2587,13 +2460,11 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
# time is an image with metadata publicly exposed,
|
# time is an image with metadata publicly exposed,
|
||||||
# even for a few mS
|
# even for a few mS
|
||||||
if m_type == 'instanceLogo':
|
if m_type == 'instanceLogo':
|
||||||
filename_base = \
|
filename_base = base_dir + '/accounts/login.temp'
|
||||||
base_dir + '/accounts/login.temp'
|
|
||||||
elif m_type == 'importTheme':
|
elif m_type == 'importTheme':
|
||||||
if not os.path.isdir(base_dir + '/imports'):
|
if not os.path.isdir(base_dir + '/imports'):
|
||||||
os.mkdir(base_dir + '/imports')
|
os.mkdir(base_dir + '/imports')
|
||||||
filename_base = \
|
filename_base = base_dir + '/imports/newtheme.zip'
|
||||||
base_dir + '/imports/newtheme.zip'
|
|
||||||
if os.path.isfile(filename_base):
|
if os.path.isfile(filename_base):
|
||||||
try:
|
try:
|
||||||
os.remove(filename_base)
|
os.remove(filename_base)
|
||||||
|
@ -2721,8 +2592,7 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
||||||
'fields could be extracted from POST')
|
'fields could be extracted from POST')
|
||||||
|
|
||||||
# load the json for the actor for this user
|
# load the json for the actor for this user
|
||||||
actor_filename = \
|
actor_filename = acct_dir(base_dir, nickname, domain) + '.json'
|
||||||
acct_dir(base_dir, nickname, domain) + '.json'
|
|
||||||
if os.path.isfile(actor_filename):
|
if os.path.isfile(actor_filename):
|
||||||
actor_json = load_json(actor_filename)
|
actor_json = load_json(actor_filename)
|
||||||
if actor_json:
|
if actor_json:
|
||||||
|
|
Loading…
Reference in New Issue