More checking of variable case

merge-requests/30/head
Bob Mottram 2021-12-30 13:56:38 +00:00
parent 1d0da992e9
commit 1aa79ce198
6 changed files with 278 additions and 135 deletions

View File

@ -951,7 +951,7 @@ def set_broch_mode(base_dir: str, domain_full: str, enabled: bool) -> None:
print('EX: Broch mode not enabled due to file write ' + str(ex)) print('EX: Broch mode not enabled due to file write ' + str(ex))
return return
set_config_param(base_dir, "broch_mode", enabled) set_config_param(base_dir, "brochMode", enabled)
def broch_modeLapses(base_dir: str, lapseDays: int) -> bool: def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
@ -982,7 +982,7 @@ def broch_modeLapses(base_dir: str, lapseDays: int) -> bool:
print('EX: broch_modeLapses allow file not deleted ' + print('EX: broch_modeLapses allow file not deleted ' +
str(allow_filename)) str(allow_filename))
if removed: if removed:
set_config_param(base_dir, "broch_mode", False) set_config_param(base_dir, "brochMode", False)
print('Broch mode has elapsed') print('Broch mode has elapsed')
return True return True
return False return False

118
daemon.py
View File

@ -5042,19 +5042,19 @@ class PubServer(BaseHTTPRequestHandler):
self.server.fontsCache = {} self.server.fontsCache = {}
self.server.show_publish_as_icon = \ self.server.show_publish_as_icon = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'show_publish_as_icon') 'showPublishAsIcon')
self.server.full_width_tl_button_header = \ self.server.full_width_tl_button_header = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'full_width_tl_button_header') 'fullWidthTlButtonHeader')
self.server.icons_as_buttons = \ self.server.icons_as_buttons = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'icons_as_buttons') 'iconsAsButtons')
self.server.rss_icon_at_top = \ self.server.rss_icon_at_top = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'rss_icon_at_top') 'rssIconAtTop')
self.server.publish_button_at_top = \ self.server.publish_button_at_top = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'publish_button_at_top') 'publishButtonAtTop')
set_news_avatar(base_dir, set_news_avatar(base_dir,
fields['themeDropdown'], fields['themeDropdown'],
http_prefix, http_prefix,
@ -5063,74 +5063,74 @@ class PubServer(BaseHTTPRequestHandler):
if nickname == adminNickname: if nickname == adminNickname:
# change media instance status # change media instance status
if fields.get('media_instance'): if fields.get('mediaInstance'):
self.server.media_instance = False self.server.media_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
if fields['media_instance'] == 'on': if fields['mediaInstance'] == 'on':
self.server.media_instance = True self.server.media_instance = True
self.server.blogs_instance = False self.server.blogs_instance = False
self.server.news_instance = False self.server.news_instance = False
self.server.defaultTimeline = 'tlmedia' self.server.defaultTimeline = 'tlmedia'
set_config_param(base_dir, "media_instance", set_config_param(base_dir, "mediaInstance",
self.server.media_instance) self.server.media_instance)
set_config_param(base_dir, "blogs_instance", set_config_param(base_dir, "blogsInstance",
self.server.blogs_instance) self.server.blogs_instance)
set_config_param(base_dir, "news_instance", set_config_param(base_dir, "newsInstance",
self.server.news_instance) self.server.news_instance)
else: else:
if self.server.media_instance: if self.server.media_instance:
self.server.media_instance = False self.server.media_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
set_config_param(base_dir, "media_instance", set_config_param(base_dir, "mediaInstance",
self.server.media_instance) self.server.media_instance)
# is this a news theme? # is this a news theme?
if is_news_theme_name(self.server.base_dir, if is_news_theme_name(self.server.base_dir,
self.server.theme_name): self.server.theme_name):
fields['news_instance'] = 'on' fields['newsInstance'] = 'on'
# change news instance status # change news instance status
if fields.get('news_instance'): if fields.get('newsInstance'):
self.server.news_instance = False self.server.news_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
if fields['news_instance'] == 'on': if fields['newsInstance'] == 'on':
self.server.news_instance = True self.server.news_instance = True
self.server.blogs_instance = False self.server.blogs_instance = False
self.server.media_instance = False self.server.media_instance = False
self.server.defaultTimeline = 'tlfeatures' self.server.defaultTimeline = 'tlfeatures'
set_config_param(base_dir, "media_instance", set_config_param(base_dir, "mediaInstance",
self.server.media_instance) self.server.media_instance)
set_config_param(base_dir, "blogs_instance", set_config_param(base_dir, "blogsInstance",
self.server.blogs_instance) self.server.blogs_instance)
set_config_param(base_dir, "news_instance", set_config_param(base_dir, "newsInstance",
self.server.news_instance) self.server.news_instance)
else: else:
if self.server.news_instance: if self.server.news_instance:
self.server.news_instance = False self.server.news_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
set_config_param(base_dir, "news_instance", set_config_param(base_dir, "newsInstance",
self.server.media_instance) self.server.media_instance)
# change blog instance status # change blog instance status
if fields.get('blogs_instance'): if fields.get('blogsInstance'):
self.server.blogs_instance = False self.server.blogs_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
if fields['blogs_instance'] == 'on': if fields['blogsInstance'] == 'on':
self.server.blogs_instance = True self.server.blogs_instance = True
self.server.media_instance = False self.server.media_instance = False
self.server.news_instance = False self.server.news_instance = False
self.server.defaultTimeline = 'tlblogs' self.server.defaultTimeline = 'tlblogs'
set_config_param(base_dir, "blogs_instance", set_config_param(base_dir, "blogsInstance",
self.server.blogs_instance) self.server.blogs_instance)
set_config_param(base_dir, "media_instance", set_config_param(base_dir, "mediaInstance",
self.server.media_instance) self.server.media_instance)
set_config_param(base_dir, "news_instance", set_config_param(base_dir, "newsInstance",
self.server.news_instance) self.server.news_instance)
else: else:
if self.server.blogs_instance: if self.server.blogs_instance:
self.server.blogs_instance = False self.server.blogs_instance = False
self.server.defaultTimeline = 'inbox' self.server.defaultTimeline = 'inbox'
set_config_param(base_dir, "blogs_instance", set_config_param(base_dir, "blogsInstance",
self.server.blogs_instance) self.server.blogs_instance)
# change instance title # change instance title
@ -5229,12 +5229,12 @@ class PubServer(BaseHTTPRequestHandler):
'libretranslateApiKey', '') 'libretranslateApiKey', '')
# change instance short description # change instance short description
if fields.get('content_license_url'): if fields.get('contentLicenseUrl'):
if fields['content_license_url'] != \ if fields['contentLicenseUrl'] != \
self.server.content_license_url: self.server.content_license_url:
licenseStr = fields['content_license_url'] licenseStr = fields['contentLicenseUrl']
set_config_param(base_dir, set_config_param(base_dir,
'content_license_url', 'contentLicenseUrl',
licenseStr) licenseStr)
self.server.content_license_url = \ self.server.content_license_url = \
licenseStr licenseStr
@ -5242,7 +5242,7 @@ class PubServer(BaseHTTPRequestHandler):
licenseStr = \ licenseStr = \
'https://creativecommons.org/licenses/by/4.0' 'https://creativecommons.org/licenses/by/4.0'
set_config_param(base_dir, set_config_param(base_dir,
'content_license_url', 'contentLicenseUrl',
licenseStr) licenseStr)
self.server.content_license_url = licenseStr self.server.content_license_url = licenseStr
@ -5555,23 +5555,23 @@ class PubServer(BaseHTTPRequestHandler):
if path.startswith('/users/' + if path.startswith('/users/' +
adminNickname + '/'): adminNickname + '/'):
show_node_info_accounts = False show_node_info_accounts = False
if fields.get('show_node_info_accounts'): if fields.get('showNodeInfoAccounts'):
if fields['show_node_info_accounts'] == '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,
"show_node_info_accounts", "showNodeInfoAccounts",
show_node_info_accounts) show_node_info_accounts)
show_node_info_version = False show_node_info_version = False
if fields.get('show_node_info_version'): if fields.get('showNodeInfoVersion'):
if fields['show_node_info_version'] == '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,
"show_node_info_version", "showNodeInfoVersion",
show_node_info_version) show_node_info_version)
verify_all_signatures = False verify_all_signatures = False
@ -5580,26 +5580,26 @@ class PubServer(BaseHTTPRequestHandler):
verify_all_signatures = True verify_all_signatures = True
self.server.verify_all_signatures = \ self.server.verify_all_signatures = \
verify_all_signatures verify_all_signatures
set_config_param(base_dir, "verify_all_signatures", set_config_param(base_dir, "verifyAllSignatures",
verify_all_signatures) verify_all_signatures)
broch_mode = False broch_mode = False
if fields.get('broch_mode'): if fields.get('brochMode'):
if fields['broch_mode'] == 'on': if fields['brochMode'] == 'on':
broch_mode = True broch_mode = True
currBrochMode = \ currBrochMode = \
get_config_param(base_dir, "broch_mode") get_config_param(base_dir, "brochMode")
if broch_mode != currBrochMode: if broch_mode != currBrochMode:
set_broch_mode(self.server.base_dir, set_broch_mode(self.server.base_dir,
self.server.domain_full, self.server.domain_full,
broch_mode) broch_mode)
set_config_param(base_dir, "broch_mode", set_config_param(base_dir, 'brochMode',
broch_mode) broch_mode)
# shared item federation domains # shared item federation domains
siDomainUpdated = False siDomainUpdated = False
fed_domains_variable = \ fed_domains_variable = \
"shared_items_federated_domains" "sharedItemsFederatedDomains"
fed_domains_str = \ fed_domains_str = \
get_config_param(base_dir, get_config_param(base_dir,
fed_domains_variable) fed_domains_variable)
@ -5619,7 +5619,7 @@ class PubServer(BaseHTTPRequestHandler):
sharedItemsFormStr2 = \ sharedItemsFormStr2 = \
shareDomainList.replace('\n', ',') shareDomainList.replace('\n', ',')
sharedItemsField = \ sharedItemsField = \
"shared_items_federated_domains" "sharedItemsFederatedDomains"
set_config_param(base_dir, set_config_param(base_dir,
sharedItemsField, sharedItemsField,
sharedItemsFormStr2) sharedItemsFormStr2)
@ -5627,7 +5627,7 @@ class PubServer(BaseHTTPRequestHandler):
else: else:
if fed_domains_str: if fed_domains_str:
sharedItemsField = \ sharedItemsField = \
"shared_items_federated_domains" "sharedItemsFederatedDomains"
set_config_param(base_dir, set_config_param(base_dir,
sharedItemsField, sharedItemsField,
'') '')
@ -5907,8 +5907,8 @@ class PubServer(BaseHTTPRequestHandler):
'artist') 'artist')
# remove scheduled posts # remove scheduled posts
if fields.get('remove_scheduled_posts'): if fields.get('removeScheduledPosts'):
if fields['remove_scheduled_posts'] == 'on': if fields['removeScheduledPosts'] == 'on':
remove_scheduled_posts(base_dir, remove_scheduled_posts(base_dir,
nickname, domain) nickname, domain)
@ -5972,20 +5972,20 @@ class PubServer(BaseHTTPRequestHandler):
self.server.fontsCache = {} self.server.fontsCache = {}
self.server.show_publish_as_icon = \ self.server.show_publish_as_icon = \
get_config_param(base_dir, get_config_param(base_dir,
'show_publish_as_icon') '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,
'fullWidthTimeline' + 'fullWidthTimeline' +
'ButtonHeader') 'ButtonHeader')
self.server.icons_as_buttons = \ self.server.icons_as_buttons = \
get_config_param(base_dir, get_config_param(base_dir,
'icons_as_buttons') 'iconsAsButtons')
self.server.rss_icon_at_top = \ self.server.rss_icon_at_top = \
get_config_param(base_dir, get_config_param(base_dir,
'rss_icon_at_top') 'rssIconAtTop')
self.server.publish_button_at_top = \ self.server.publish_button_at_top = \
get_config_param(base_dir, get_config_param(base_dir,
'publish_button_at_top') 'publishButtonAtTop')
# only receive DMs from accounts you follow # only receive DMs from accounts you follow
followDMsFilename = \ followDMsFilename = \
@ -6219,13 +6219,13 @@ class PubServer(BaseHTTPRequestHandler):
if path.startswith('/users/' + adminNickname + '/') or \ if path.startswith('/users/' + adminNickname + '/') or \
is_artist(base_dir, nickname): is_artist(base_dir, nickname):
currLowBandwidth = \ currLowBandwidth = \
get_config_param(base_dir, 'low_bandwidth') get_config_param(base_dir, 'lowBandwidth')
low_bandwidth = False low_bandwidth = False
if fields.get('low_bandwidth'): if fields.get('lowBandwidth'):
if fields['low_bandwidth'] == 'on': if fields['lowBandwidth'] == 'on':
low_bandwidth = True low_bandwidth = True
if currLowBandwidth != low_bandwidth: if currLowBandwidth != low_bandwidth:
set_config_param(base_dir, 'low_bandwidth', set_config_param(base_dir, 'lowBandwidth',
low_bandwidth) low_bandwidth)
self.server.low_bandwidth = low_bandwidth self.server.low_bandwidth = low_bandwidth
@ -6407,14 +6407,14 @@ class PubServer(BaseHTTPRequestHandler):
if newListsEnabled != self.server.lists_enabled: if newListsEnabled != self.server.lists_enabled:
self.server.lists_enabled = newListsEnabled self.server.lists_enabled = newListsEnabled
set_config_param(self.server.base_dir, set_config_param(self.server.base_dir,
"lists_enabled", "listsEnabled",
newListsEnabled) newListsEnabled)
# save blocked user agents # save blocked user agents
user_agents_blocked = [] user_agents_blocked = []
if fields.get('user_agents_blockedStr'): if fields.get('userAgentsBlockedStr'):
user_agents_blockedStr = \ user_agents_blockedStr = \
fields['user_agents_blockedStr'] fields['userAgentsBlockedStr']
user_agents_blockedList = \ user_agents_blockedList = \
user_agents_blockedStr.split('\n') user_agents_blockedStr.split('\n')
for ua in user_agents_blockedList: for ua in user_agents_blockedList:
@ -18059,7 +18059,7 @@ class PubServer(BaseHTTPRequestHandler):
if not self.server.shared_items_federated_domains: if not self.server.shared_items_federated_domains:
siDomainsStr = \ siDomainsStr = \
get_config_param(self.server.base_dir, get_config_param(self.server.base_dir,
'shared_items_federated_domains') 'sharedItemsFederatedDomains')
if siDomainsStr: if siDomainsStr:
if self.server.debug: if self.server.debug:
print('Loading shared items federated domains list') print('Loading shared items federated domains list')
@ -18899,7 +18899,7 @@ def run_daemon(content_license_url: str,
if not os.path.isdir(base_dir + '/accounts/news@' + domain): if not os.path.isdir(base_dir + '/accounts/news@' + domain):
print('Creating news inbox: news@' + domain) print('Creating news inbox: news@' + domain)
create_news_inbox(base_dir, domain, port, http_prefix) create_news_inbox(base_dir, domain, port, http_prefix)
set_config_param(base_dir, "lists_enabled", "Murdoch press") set_config_param(base_dir, "listsEnabled", "Murdoch press")
# dict of known web crawlers accessing nodeinfo or the masto API # dict of known web crawlers accessing nodeinfo or the masto API
# and how many times they have been seen # and how many times they have been seen
@ -18913,7 +18913,7 @@ def run_daemon(content_license_url: str,
if lists_enabled: if lists_enabled:
httpd.lists_enabled = lists_enabled httpd.lists_enabled = lists_enabled
else: else:
httpd.lists_enabled = get_config_param(base_dir, "lists_enabled") httpd.lists_enabled = get_config_param(base_dir, "listsEnabled")
httpd.cw_lists = load_cw_lists(base_dir, True) httpd.cw_lists = load_cw_lists(base_dir, True)
# set the avatar for the news account # set the avatar for the news account

View File

@ -1001,7 +1001,7 @@ if not theme_name:
theme_name = 'default' theme_name = 'default'
if not args.mediainstance: if not args.mediainstance:
media_instance = get_config_param(base_dir, 'media_instance') media_instance = get_config_param(base_dir, 'mediaInstance')
if media_instance is not None: if media_instance is not None:
args.mediainstance = media_instance args.mediainstance = media_instance
if args.mediainstance: if args.mediainstance:
@ -1009,7 +1009,7 @@ if not args.mediainstance:
args.newsinstance = False args.newsinstance = False
if not args.newsinstance: if not args.newsinstance:
news_instance = get_config_param(base_dir, 'news_instance') news_instance = get_config_param(base_dir, 'newsInstance')
if news_instance is not None: if news_instance is not None:
args.newsinstance = news_instance args.newsinstance = news_instance
if args.newsinstance: if args.newsinstance:
@ -1017,7 +1017,7 @@ if not args.newsinstance:
args.mediainstance = False args.mediainstance = False
if not args.blogsinstance: if not args.blogsinstance:
blogs_instance = get_config_param(base_dir, 'blogs_instance') blogs_instance = get_config_param(base_dir, 'blogsInstance')
if blogs_instance is not None: if blogs_instance is not None:
args.blogsinstance = blogs_instance args.blogsinstance = blogs_instance
if args.blogsinstance: if args.blogsinstance:
@ -1069,7 +1069,7 @@ if args.i2p_domain:
if '://' in args.i2p_domain: if '://' in args.i2p_domain:
args.onion = args.onion.split('://')[1] args.onion = args.onion.split('://')[1]
i2p_domain = args.i2p_domain i2p_domain = args.i2p_domain
set_config_param(base_dir, 'i2p_domain', i2p_domain) set_config_param(base_dir, 'i2pDomain', i2p_domain)
if not args.language: if not args.language:
languageCode = get_config_param(base_dir, 'language') languageCode = get_config_param(base_dir, 'language')
@ -1103,10 +1103,10 @@ if args.resetregistrations:
print('Number of new registrations reset to ' + str(maxRegistrations)) print('Number of new registrations reset to ' + str(maxRegistrations))
# unique ID for the instance # unique ID for the instance
instance_id = get_config_param(base_dir, 'instance_id') instance_id = get_config_param(base_dir, 'instanceId')
if not instance_id: if not instance_id:
instance_id = create_password(32) instance_id = create_password(32)
set_config_param(base_dir, 'instance_id', instance_id) set_config_param(base_dir, 'instanceId', instance_id)
print('Instance ID: ' + instance_id) print('Instance ID: ' + instance_id)
# get domain name from configuration # get domain name from configuration
@ -1124,7 +1124,7 @@ else:
onion_domain = None onion_domain = None
# get i2p domain name from configuration # get i2p domain name from configuration
configi2p_domain = get_config_param(base_dir, 'i2p_domain') configi2p_domain = get_config_param(base_dir, 'i2pDomain')
if configi2p_domain: if configi2p_domain:
i2p_domain = configi2p_domain i2p_domain = configi2p_domain
else: else:
@ -1141,7 +1141,7 @@ else:
else: else:
port = 443 port = 443
configProxyPort = get_config_param(base_dir, 'proxy_port') configProxyPort = get_config_param(base_dir, 'proxyPort')
if configProxyPort: if configProxyPort:
proxy_port = configProxyPort proxy_port = configProxyPort
else: else:
@ -1163,9 +1163,9 @@ if args.federation_list:
': Federate with domains, not individual accounts') ': Federate with domains, not individual accounts')
sys.exit() sys.exit()
federation_list = args.federation_list.copy() federation_list = args.federation_list.copy()
set_config_param(base_dir, 'federation_list', federation_list) set_config_param(base_dir, 'federationList', federation_list)
else: else:
configFederationList = get_config_param(base_dir, 'federation_list') configFederationList = get_config_param(base_dir, 'federationList')
if configFederationList: if configFederationList:
federation_list = configFederationList federation_list = configFederationList
@ -2068,7 +2068,7 @@ if args.port:
set_config_param(base_dir, 'port', port) set_config_param(base_dir, 'port', port)
if args.proxy_port: if args.proxy_port:
proxy_port = args.proxy_port proxy_port = args.proxy_port
set_config_param(base_dir, 'proxy_port', proxy_port) set_config_param(base_dir, 'proxyPort', proxy_port)
if args.gnunet: if args.gnunet:
http_prefix = 'gnunet' http_prefix = 'gnunet'
if args.dat or args.hyper: if args.dat or args.hyper:
@ -2615,11 +2615,11 @@ if args.shared_items_federated_domains:
shared_items_federated_domains = [] shared_items_federated_domains = []
if args.shared_items_federated_domains: if args.shared_items_federated_domains:
fed_domains_str = args.shared_items_federated_domains fed_domains_str = args.shared_items_federated_domains
set_config_param(base_dir, 'shared_items_federated_domains', set_config_param(base_dir, 'sharedItemsFederatedDomains',
fed_domains_str) fed_domains_str)
else: else:
fed_domains_str = \ fed_domains_str = \
get_config_param(base_dir, 'shared_items_federated_domains') get_config_param(base_dir, 'sharedItemsFederatedDomains')
if fed_domains_str: if fed_domains_str:
fed_domains_list = fed_domains_str.split(',') fed_domains_list = fed_domains_str.split(',')
for sharedFederatedDomain in fed_domains_list: for sharedFederatedDomain in fed_domains_list:
@ -3017,9 +3017,9 @@ if minimumvotes:
content_license_url = '' content_license_url = ''
if args.content_license_url: if args.content_license_url:
content_license_url = args.content_license_url content_license_url = args.content_license_url
set_config_param(base_dir, 'content_license_url', content_license_url) set_config_param(base_dir, 'contentLicenseUrl', content_license_url)
else: else:
content_license_url = get_config_param(base_dir, 'content_license_url') content_license_url = get_config_param(base_dir, 'contentLicenseUrl')
votingtime = get_config_param(base_dir, 'votingtime') votingtime = get_config_param(base_dir, 'votingtime')
if votingtime: if votingtime:
@ -3032,124 +3032,124 @@ if dateonly:
# set the maximum number of newswire posts per account or rss feed # set the maximum number of newswire posts per account or rss feed
max_newswire_postsPerSource = \ max_newswire_postsPerSource = \
get_config_param(base_dir, 'max_newswire_postsPerSource') get_config_param(base_dir, 'maxNewswirePostsPerSource')
if max_newswire_postsPerSource: if max_newswire_postsPerSource:
args.max_newswire_postsPerSource = int(max_newswire_postsPerSource) args.max_newswire_postsPerSource = int(max_newswire_postsPerSource)
# set the maximum number of newswire posts appearing in the right column # set the maximum number of newswire posts appearing in the right column
max_newswire_posts = \ max_newswire_posts = \
get_config_param(base_dir, 'max_newswire_posts') get_config_param(base_dir, 'maxNewswirePosts')
if max_newswire_posts: if max_newswire_posts:
args.max_newswire_posts = int(max_newswire_posts) args.max_newswire_posts = int(max_newswire_posts)
# set the maximum size of a newswire rss/atom feed in Kilobytes # set the maximum size of a newswire rss/atom feed in Kilobytes
max_newswire_feed_size_kb = \ max_newswire_feed_size_kb = \
get_config_param(base_dir, 'max_newswire_feed_size_kb') get_config_param(base_dir, 'maxNewswireFeedSizeKb')
if max_newswire_feed_size_kb: if max_newswire_feed_size_kb:
args.max_newswire_feed_size_kb = int(max_newswire_feed_size_kb) args.max_newswire_feed_size_kb = int(max_newswire_feed_size_kb)
max_mirrored_articles = \ max_mirrored_articles = \
get_config_param(base_dir, 'max_mirrored_articles') get_config_param(base_dir, 'maxMirroredArticles')
if max_mirrored_articles is not None: if max_mirrored_articles is not None:
args.max_mirrored_articles = int(max_mirrored_articles) args.max_mirrored_articles = int(max_mirrored_articles)
max_news_posts = \ max_news_posts = \
get_config_param(base_dir, 'max_news_posts') get_config_param(base_dir, 'maxNewsPosts')
if max_news_posts is not None: if max_news_posts is not None:
args.max_news_posts = int(max_news_posts) args.max_news_posts = int(max_news_posts)
max_followers = \ max_followers = \
get_config_param(base_dir, 'max_followers') get_config_param(base_dir, 'maxFollowers')
if max_followers is not None: if max_followers is not None:
args.max_followers = int(max_followers) args.max_followers = int(max_followers)
max_feed_item_size_kb = \ max_feed_item_size_kb = \
get_config_param(base_dir, 'max_feed_item_size_kb') get_config_param(base_dir, 'maxFeedItemSizeKb')
if max_feed_item_size_kb is not None: if max_feed_item_size_kb is not None:
args.max_feed_item_size_kb = int(max_feed_item_size_kb) args.max_feed_item_size_kb = int(max_feed_item_size_kb)
dormant_months = \ dormant_months = \
get_config_param(base_dir, 'dormant_months') get_config_param(base_dir, 'dormantMonths')
if dormant_months is not None: if dormant_months is not None:
args.dormant_months = int(dormant_months) args.dormant_months = int(dormant_months)
send_threads_timeout_mins = \ send_threads_timeout_mins = \
get_config_param(base_dir, 'send_threads_timeout_mins') get_config_param(base_dir, 'sendThreadsTimeoutMins')
if send_threads_timeout_mins is not None: if send_threads_timeout_mins is not None:
args.send_threads_timeout_mins = int(send_threads_timeout_mins) args.send_threads_timeout_mins = int(send_threads_timeout_mins)
max_like_count = \ max_like_count = \
get_config_param(base_dir, 'max_like_count') get_config_param(base_dir, 'maxLikeCount')
if max_like_count is not None: if max_like_count is not None:
args.max_like_count = int(max_like_count) args.max_like_count = int(max_like_count)
show_publish_as_icon = \ show_publish_as_icon = \
get_config_param(base_dir, 'show_publish_as_icon') get_config_param(base_dir, 'showPublishAsIcon')
if show_publish_as_icon is not None: if show_publish_as_icon is not None:
args.show_publish_as_icon = bool(show_publish_as_icon) args.show_publish_as_icon = bool(show_publish_as_icon)
icons_as_buttons = \ icons_as_buttons = \
get_config_param(base_dir, 'icons_as_buttons') get_config_param(base_dir, 'iconsAsButtons')
if icons_as_buttons is not None: if icons_as_buttons is not None:
args.icons_as_buttons = bool(icons_as_buttons) args.icons_as_buttons = bool(icons_as_buttons)
rss_icon_at_top = \ rss_icon_at_top = \
get_config_param(base_dir, 'rss_icon_at_top') get_config_param(base_dir, 'rssIconAtTop')
if rss_icon_at_top is not None: if rss_icon_at_top is not None:
args.rss_icon_at_top = bool(rss_icon_at_top) args.rss_icon_at_top = bool(rss_icon_at_top)
publish_button_at_top = \ publish_button_at_top = \
get_config_param(base_dir, 'publish_button_at_top') get_config_param(base_dir, 'publishButtonAtTop')
if publish_button_at_top is not None: if publish_button_at_top is not None:
args.publish_button_at_top = bool(publish_button_at_top) args.publish_button_at_top = bool(publish_button_at_top)
full_width_tl_button_header = \ full_width_tl_button_header = \
get_config_param(base_dir, 'full_width_tl_button_header') get_config_param(base_dir, 'fullWidthTlButtonHeader')
if full_width_tl_button_header is not None: if full_width_tl_button_header is not None:
args.full_width_tl_button_header = bool(full_width_tl_button_header) args.full_width_tl_button_header = bool(full_width_tl_button_header)
allow_local_network_access = \ allow_local_network_access = \
get_config_param(base_dir, 'allow_local_network_access') get_config_param(base_dir, 'allowLocalNetworkAccess')
if allow_local_network_access is not None: if allow_local_network_access is not None:
args.allow_local_network_access = bool(allow_local_network_access) args.allow_local_network_access = bool(allow_local_network_access)
verify_all_signatures = \ verify_all_signatures = \
get_config_param(base_dir, 'verify_all_signatures') get_config_param(base_dir, 'verifyAllSignatures')
if verify_all_signatures is not None: if verify_all_signatures is not None:
args.verify_all_signatures = bool(verify_all_signatures) args.verify_all_signatures = bool(verify_all_signatures)
broch_mode = \ broch_mode = \
get_config_param(base_dir, 'broch_mode') get_config_param(base_dir, 'brochMode')
if broch_mode is not None: if broch_mode is not None:
args.broch_mode = bool(broch_mode) args.broch_mode = bool(broch_mode)
log_login_failures = \ log_login_failures = \
get_config_param(base_dir, 'log_login_failures') get_config_param(base_dir, 'logLoginFailures')
if log_login_failures is not None: if log_login_failures is not None:
args.log_login_failures = bool(log_login_failures) args.log_login_failures = bool(log_login_failures)
show_node_info_accounts = \ show_node_info_accounts = \
get_config_param(base_dir, 'show_node_info_accounts') get_config_param(base_dir, 'showNodeInfoAccounts')
if show_node_info_accounts is not None: if show_node_info_accounts is not None:
args.show_node_info_accounts = bool(show_node_info_accounts) args.show_node_info_accounts = bool(show_node_info_accounts)
show_node_info_version = \ show_node_info_version = \
get_config_param(base_dir, 'show_node_info_version') get_config_param(base_dir, 'showNodeInfoVersion')
if show_node_info_version is not None: if show_node_info_version is not None:
args.show_node_info_version = bool(show_node_info_version) args.show_node_info_version = bool(show_node_info_version)
low_bandwidth = \ low_bandwidth = \
get_config_param(base_dir, 'low_bandwidth') get_config_param(base_dir, 'lowBandwidth')
if low_bandwidth is not None: if low_bandwidth is not None:
args.low_bandwidth = bool(low_bandwidth) args.low_bandwidth = bool(low_bandwidth)
user_agents_blocked = [] user_agents_blocked = []
if args.userAgentBlocks: if args.userAgentBlocks:
user_agents_blockedStr = args.userAgentBlocks user_agents_blockedStr = args.userAgentBlocks
set_config_param(base_dir, 'user_agents_blocked', user_agents_blockedStr) set_config_param(base_dir, 'userAgentsBlocked', user_agents_blockedStr)
else: else:
user_agents_blockedStr = \ user_agents_blockedStr = \
get_config_param(base_dir, 'user_agents_blocked') get_config_param(base_dir, 'userAgentsBlocked')
if user_agents_blockedStr: if user_agents_blockedStr:
agentBlocksList = user_agents_blockedStr.split(',') agentBlocksList = user_agents_blockedStr.split(',')
for agentBlockStr in agentBlocksList: for agentBlockStr in agentBlocksList:
@ -3158,9 +3158,9 @@ if user_agents_blockedStr:
lists_enabled = '' lists_enabled = ''
if args.lists_enabled: if args.lists_enabled:
lists_enabled = args.lists_enabled lists_enabled = args.lists_enabled
set_config_param(base_dir, 'lists_enabled', lists_enabled) set_config_param(base_dir, 'listsEnabled', lists_enabled)
else: else:
lists_enabled = get_config_param(base_dir, 'lists_enabled') lists_enabled = get_config_param(base_dir, 'listsEnabled')
city = \ city = \
get_config_param(base_dir, 'city') get_config_param(base_dir, 'city')

View File

@ -4233,7 +4233,7 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
'accounts': {} 'accounts': {}
} }
# also check if the json signature enforcement has changed # also check if the json signature enforcement has changed
verifyAllSigs = get_config_param(base_dir, "verify_all_signatures") verifyAllSigs = get_config_param(base_dir, "verifyAllSignatures")
if verifyAllSigs is not None: if verifyAllSigs is not None:
verify_all_signatures = verifyAllSigs verify_all_signatures = verifyAllSigs
# change the last time that this was done # change the last time that this was done
@ -4515,8 +4515,8 @@ def run_inbox_queue(recent_posts_cache: {}, max_recent_posts: int,
if not os.path.isfile(sharedInboxPostFilename): if not os.path.isfile(sharedInboxPostFilename):
save_json(queueJson['post'], sharedInboxPostFilename) save_json(queueJson['post'], sharedInboxPostFilename)
lists_enabled = get_config_param(base_dir, "lists_enabled") lists_enabled = get_config_param(base_dir, "listsEnabled")
content_license_url = get_config_param(base_dir, "content_license_url") content_license_url = get_config_param(base_dir, "contentLicenseUrl")
# for posts addressed to specific accounts # for posts addressed to specific accounts
for handle, capsId in recipientsDict.items(): for handle, capsId in recipientsDict.items():

149
tests.py
View File

@ -1727,8 +1727,8 @@ def test_shared_items_federation(base_dir: str) -> None:
print("Alice and Bob agree to share items catalogs") print("Alice and Bob agree to share items catalogs")
assert os.path.isdir(aliceDir) assert os.path.isdir(aliceDir)
assert os.path.isdir(bobDir) assert os.path.isdir(bobDir)
set_config_param(aliceDir, 'shared_items_federated_domains', bobAddress) set_config_param(aliceDir, 'sharedItemsFederatedDomains', bobAddress)
set_config_param(bobDir, 'shared_items_federated_domains', aliceAddress) set_config_param(bobDir, 'sharedItemsFederatedDomains', aliceAddress)
print('*********************************************************') print('*********************************************************')
print('Alice sends a follow request to Bob') print('Alice sends a follow request to Bob')
@ -4490,7 +4490,147 @@ def _test_post_variable_names():
if '_' in name_var: if '_' in name_var:
print(name_var + ' is not camel case POST variable in ' + print(name_var + ' is not camel case POST variable in ' +
source_file) source_file)
return False assert False
break
def _test_config_param_names():
print('testConfigParamNames')
fnames = ('get_config_param', 'set_config_param')
for subdir, dirs, files in os.walk('.'):
for source_file in files:
if not source_file.endswith('.py'):
continue
if source_file.startswith('.#'):
continue
if source_file.startswith('flycheck_'):
continue
source_str = ''
with open(source_file, 'r') as file_source:
source_str = file_source.read()
if not source_str:
continue
for fname in fnames:
if fname + '(' not in source_str:
continue
names_list = source_str.split(fname + '(')
for index in range(1, len(names_list)):
param_var_name = None
if '"' in names_list[index]:
param_var_name = names_list[index].split('"')[1]
elif "'" in names_list[index]:
param_var_name = names_list[index].split("'")[1]
if not param_var_name:
continue
if ' ' in param_var_name:
continue
if '.' in param_var_name:
continue
if '/' in param_var_name:
continue
if '__' in param_var_name:
continue
if 'POST' in param_var_name:
continue
if param_var_name.isdigit():
continue
if '_' in param_var_name:
print(fname + ' in ' + source_file +
' should have camel case variable ' +
param_var_name)
assert False
break
def _test_checkbox_names():
print('testCheckboxNames')
fnames = ['edit_text_field', 'edit_check_box', 'edit_text_area']
for subdir, dirs, files in os.walk('.'):
for source_file in files:
if not source_file.endswith('.py'):
continue
if source_file.startswith('.#'):
continue
if source_file.startswith('flycheck_'):
continue
source_str = ''
with open(source_file, 'r') as file_source:
source_str = file_source.read()
if not source_str:
continue
for fname in fnames:
if fname + '(' not in source_str:
continue
names_list = source_str.split(fname + '(')
for index in range(1, len(names_list)):
if ')' not in names_list[index]:
continue
allparams = names_list[index].split(')')[0]
if ',' not in allparams:
continue
allparams_list = allparams.split(',')
if len(allparams_list) < 2:
continue
param_var_name = allparams_list[1].strip()
param_var_name = param_var_name.replace('"', '')
param_var_name = param_var_name.replace("'", '')
if ' ' in param_var_name:
continue
if '/' in param_var_name:
continue
if '_' in param_var_name:
print(fname + ' in ' + source_file +
' should have camel case variable ' +
param_var_name)
assert False
break
def _test_post_field_names():
print('testPOSTfieldNames')
fnames = ['fields.get']
source_file = 'daemon.py'
source_str = ''
with open(source_file, 'r') as file_source:
source_str = file_source.read()
if not source_str:
return
for fname in fnames:
if fname + '(' not in source_str:
continue
names_list = source_str.split(fname + '(')
for index in range(1, len(names_list)):
if ')' not in names_list[index]:
continue
param_var_name = names_list[index].split(')')[0].strip()
orig_param_var_name = fname + '(' + param_var_name + ')'
param_var_name = param_var_name.replace('"', '')
param_var_name = param_var_name.replace("'", '')
if ' ' in param_var_name:
continue
if '/' in param_var_name:
continue
if '_' in param_var_name:
print(orig_param_var_name + ' in ' + source_file +
' should be camel case')
assert False
if ' fields[' in source_str:
names_list = source_str.split(' fields[')
for index in range(1, len(names_list)):
if ']' not in names_list[index]:
continue
param_var_name = names_list[index].split(']')[0].strip()
orig_param_var_name = 'fields[' + param_var_name + ']'
param_var_name = param_var_name.replace('"', '')
param_var_name = param_var_name.replace("'", '')
if '_' in param_var_name:
print(orig_param_var_name + ' in ' + source_file +
' should be camel case')
assert False
def _test_functions(): def _test_functions():
@ -6139,6 +6279,9 @@ def run_all_tests():
_translate_ontology(base_dir) _translate_ontology(base_dir)
_test_get_price_from_string() _test_get_price_from_string()
_test_post_variable_names() _test_post_variable_names()
_test_config_param_names()
_test_post_field_names()
_test_checkbox_names()
_test_functions() _test_functions()
_test_get_actor_from_in_reply_to() _test_get_actor_from_in_reply_to()
_test_valid_emoji_content() _test_valid_emoji_content()

View File

@ -1266,7 +1266,7 @@ def _html_edit_profile_graphic_design(base_dir: str, translate: {}) -> str:
graphicsStr = begin_edit_section(translate['Graphic Design']) graphicsStr = begin_edit_section(translate['Graphic Design'])
low_bandwidth = get_config_param(base_dir, 'low_bandwidth') low_bandwidth = get_config_param(base_dir, 'lowBandwidth')
if not low_bandwidth: if not low_bandwidth:
low_bandwidth = False low_bandwidth = False
graphicsStr += _html_themes_dropdown(base_dir, translate) graphicsStr += _html_themes_dropdown(base_dir, translate)
@ -1283,7 +1283,7 @@ def _html_edit_profile_graphic_design(base_dir: str, translate: {}) -> str:
' <button type="submit" class="button" ' + \ ' <button type="submit" class="button" ' + \
'name="submitExportTheme">➤</button><br>\n' 'name="submitExportTheme">➤</button><br>\n'
graphicsStr += \ graphicsStr += \
edit_check_box(translate['Low Bandwidth'], 'low_bandwidth', edit_check_box(translate['Low Bandwidth'], 'lowBandwidth',
bool(low_bandwidth)) bool(low_bandwidth))
graphicsStr += end_edit_section() graphicsStr += end_edit_section()
@ -1328,7 +1328,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
instanceTitle = \ instanceTitle = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')
content_license_url = \ content_license_url = \
get_config_param(base_dir, 'content_license_url') get_config_param(base_dir, 'contentLicenseUrl')
if not content_license_url: if not content_license_url:
content_license_url = 'https://creativecommons.org/licenses/by/4.0' content_license_url = 'https://creativecommons.org/licenses/by/4.0'
@ -1348,7 +1348,7 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'', True) '', True)
instanceStr += \ instanceStr += \
edit_text_field(translate['Content License'], edit_text_field(translate['Content License'],
'content_license_url', content_license_url) 'contentLicenseUrl', content_license_url)
instanceStr += '<br>\n' instanceStr += '<br>\n'
instanceStr += \ instanceStr += \
edit_text_field(translate['Custom post submit button text'], edit_text_field(translate['Custom post submit button text'],
@ -1364,23 +1364,23 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
nodeInfoStr = \ nodeInfoStr = \
translate['Show numbers of accounts within instance metadata'] translate['Show numbers of accounts within instance metadata']
if get_config_param(base_dir, "show_node_info_accounts"): if get_config_param(base_dir, "showNodeInfoAccounts"):
instanceStr += \ instanceStr += \
edit_check_box(nodeInfoStr, 'show_node_info_accounts', True) edit_check_box(nodeInfoStr, 'showNodeInfoAccounts', True)
else: else:
instanceStr += \ instanceStr += \
edit_check_box(nodeInfoStr, 'show_node_info_accounts', False) edit_check_box(nodeInfoStr, 'showNodeInfoAccounts', False)
nodeInfoStr = \ nodeInfoStr = \
translate['Show version number within instance metadata'] translate['Show version number within instance metadata']
if get_config_param(base_dir, "show_node_info_version"): if get_config_param(base_dir, "showNodeInfoVersion"):
instanceStr += \ instanceStr += \
edit_check_box(nodeInfoStr, 'show_node_info_version', True) edit_check_box(nodeInfoStr, 'showNodeInfoVersion', True)
else: else:
instanceStr += \ instanceStr += \
edit_check_box(nodeInfoStr, 'show_node_info_version', False) edit_check_box(nodeInfoStr, 'showNodeInfoVersion', False)
if get_config_param(base_dir, "verify_all_signatures"): if get_config_param(base_dir, "verifyAllSignatures"):
instanceStr += \ instanceStr += \
edit_check_box(translate['Verify all signatures'], edit_check_box(translate['Verify all signatures'],
'verifyallsignatures', True) 'verifyallsignatures', True)
@ -1390,25 +1390,25 @@ def _html_edit_profile_instance(base_dir: str, translate: {},
'verifyallsignatures', False) 'verifyallsignatures', False)
instanceStr += translate['Enabling broch mode'] + '<br>\n' instanceStr += translate['Enabling broch mode'] + '<br>\n'
if get_config_param(base_dir, "broch_mode"): if get_config_param(base_dir, "brochMode"):
instanceStr += \ instanceStr += \
edit_check_box(translate['Broch mode'], 'broch_mode', True) edit_check_box(translate['Broch mode'], 'brochMode', True)
else: else:
instanceStr += \ instanceStr += \
edit_check_box(translate['Broch mode'], 'broch_mode', False) edit_check_box(translate['Broch mode'], 'brochMode', False)
# Instance type # Instance type
instanceStr += \ instanceStr += \
' <br><label class="labels">' + \ ' <br><label class="labels">' + \
translate['Type of instance'] + '</label><br>\n' translate['Type of instance'] + '</label><br>\n'
instanceStr += \ instanceStr += \
edit_check_box(translate['This is a media instance'], edit_check_box(translate['This is a media instance'],
'media_instance', media_instanceStr) 'mediaInstance', media_instanceStr)
instanceStr += \ instanceStr += \
edit_check_box(translate['This is a blogging instance'], edit_check_box(translate['This is a blogging instance'],
'blogs_instance', blogs_instanceStr) 'blogsInstance', blogs_instanceStr)
instanceStr += \ instanceStr += \
edit_check_box(translate['This is a news instance'], edit_check_box(translate['This is a news instance'],
'news_instance', news_instanceStr) 'newsInstance', news_instanceStr)
instanceStr += end_edit_section() instanceStr += end_edit_section()
@ -1590,7 +1590,7 @@ def _html_edit_profile_shared_items(base_dir: str, nickname: str, domain: str,
""" """
sharedItemsStr = '' sharedItemsStr = ''
shared_items_federated_domainsStr = \ shared_items_federated_domainsStr = \
get_config_param(base_dir, 'shared_items_federated_domains') get_config_param(base_dir, 'sharedItemsFederatedDomains')
if shared_items_federated_domainsStr: if shared_items_federated_domainsStr:
shared_items_federated_domainsList = \ shared_items_federated_domainsList = \
shared_items_federated_domainsStr.split(',') shared_items_federated_domainsStr.split(',')
@ -1774,14 +1774,14 @@ def _html_edit_profile_filtering(base_dir: str, nickname: str, domain: str,
'<a href="/users/' + nickname + '/crawlers">' + \ '<a href="/users/' + nickname + '/crawlers">' + \
translate['Known Web Crawlers'] + '</a><br>\n' translate['Known Web Crawlers'] + '</a><br>\n'
user_agents_blockedStr = '' user_agents_blocked_str = ''
for ua in user_agents_blocked: for ua in user_agents_blocked:
if user_agents_blockedStr: if user_agents_blocked_str:
user_agents_blockedStr += '\n' user_agents_blocked_str += '\n'
user_agents_blockedStr += ua user_agents_blocked_str += ua
editProfileForm += \ editProfileForm += \
edit_text_area(translate['Blocked User Agents'], edit_text_area(translate['Blocked User Agents'],
'user_agents_blockedStr', user_agents_blockedStr, 'userAgentsBlockedStr', user_agents_blocked_str,
200, '', False) 200, '', False)
cw_listsStr = '' cw_listsStr = ''
@ -2095,7 +2095,7 @@ def _html_edit_profile_top_banner(base_dir: str,
editProfileForm += ' <div class="container">\n' editProfileForm += ' <div class="container">\n'
editProfileForm += \ editProfileForm += \
edit_check_box(translate['Remove scheduled posts'], edit_check_box(translate['Remove scheduled posts'],
'remove_scheduled_posts', False) 'removeScheduledPosts', False)
editProfileForm += ' </div>\n' editProfileForm += ' </div>\n'
return editProfileForm return editProfileForm
@ -2189,19 +2189,19 @@ def html_edit_profile(css_cache: {}, translate: {}, base_dir: str, path: str,
if os.path.isfile(accountDir + '/.hideReactionButton'): if os.path.isfile(accountDir + '/.hideReactionButton'):
hideReactionButton = 'checked' hideReactionButton = 'checked'
media_instance = get_config_param(base_dir, "media_instance") media_instance = get_config_param(base_dir, "mediaInstance")
if media_instance: if media_instance:
if media_instance is True: if media_instance is True:
media_instanceStr = 'checked' media_instanceStr = 'checked'
blogs_instanceStr = news_instanceStr = '' blogs_instanceStr = news_instanceStr = ''
news_instance = get_config_param(base_dir, "news_instance") news_instance = get_config_param(base_dir, "newsInstance")
if news_instance: if news_instance:
if news_instance is True: if news_instance is True:
news_instanceStr = 'checked' news_instanceStr = 'checked'
blogs_instanceStr = media_instanceStr = '' blogs_instanceStr = media_instanceStr = ''
blogs_instance = get_config_param(base_dir, "blogs_instance") blogs_instance = get_config_param(base_dir, "blogsInstance")
if blogs_instance: if blogs_instance:
if blogs_instance is True: if blogs_instance is True:
blogs_instanceStr = 'checked' blogs_instanceStr = 'checked'