diff --git a/blog.py b/blog.py index 1eb09dfe9..fb8ef8b93 100644 --- a/blog.py +++ b/blog.py @@ -23,7 +23,7 @@ from utils import get_base_content_from_post from utils import get_content_from_post from utils import isAccountDir from utils import removeHtml -from utils import getConfigParam +from utils import get_config_param from utils import get_full_domain from utils import getMediaFormats from utils import getNicknameFromActor @@ -457,7 +457,7 @@ def htmlBlogPost(session, authorized: bool, if os.path.isfile(base_dir + '/blog.css'): cssFilename = base_dir + '/blog.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') published = post_json_object['object']['published'] modified = published if post_json_object['object'].get('updated'): @@ -521,7 +521,7 @@ def htmlBlogPage(authorized: bool, session, if os.path.isfile(base_dir + '/epicyon.css'): cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) _htmlBlogRemoveCwButton(blogStr, translate) @@ -741,7 +741,7 @@ def htmlBlogView(authorized: bool, if os.path.isfile(base_dir + '/epicyon.css'): cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') blogStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) if _noOfBlogAccounts(base_dir) <= 1: @@ -847,7 +847,7 @@ def htmlEditBlog(media_instance: bool, translate: {}, dateAndLocation += '' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') editBlogForm = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) diff --git a/daemon.py b/daemon.py index ace5277b3..d28174a9a 100644 --- a/daemon.py +++ b/daemon.py @@ -284,7 +284,7 @@ from utils import clearFromPostCaches from utils import containsInvalidChars from utils import isSystemAccount from utils import setConfigParam -from utils import getConfigParam +from utils import get_config_param from utils import removeIdEnding from utils import undoLikesCollectionEntry from utils import deletePost @@ -2484,7 +2484,7 @@ class PubServer(BaseHTTPRequestHandler): # person options screen, permission to post to newswire # See htmlPersonOptions if '&submitPostToNews=' in optionsConfirmParams: - adminNickname = getConfigParam(self.server.base_dir, 'admin') + adminNickname = get_config_param(self.server.base_dir, 'admin') if (chooserNickname != optionsNickname and (chooserNickname == adminNickname or (isModerator(self.server.base_dir, chooserNickname) and @@ -2529,7 +2529,7 @@ class PubServer(BaseHTTPRequestHandler): # person options screen, permission to post to featured articles # See htmlPersonOptions if '&submitPostToFeatures=' in optionsConfirmParams: - adminNickname = getConfigParam(self.server.base_dir, 'admin') + adminNickname = get_config_param(self.server.base_dir, 'admin') if (chooserNickname != optionsNickname and (chooserNickname == adminNickname or (isModerator(self.server.base_dir, chooserNickname) and @@ -2575,7 +2575,7 @@ class PubServer(BaseHTTPRequestHandler): # person options screen, permission to post to newswire # See htmlPersonOptions if '&submitModNewsPosts=' in optionsConfirmParams: - adminNickname = getConfigParam(self.server.base_dir, 'admin') + adminNickname = get_config_param(self.server.base_dir, 'admin') if (chooserNickname != optionsNickname and (chooserNickname == adminNickname or (isModerator(self.server.base_dir, chooserNickname) and @@ -2698,7 +2698,7 @@ class PubServer(BaseHTTPRequestHandler): if self.server.keyShortcuts.get(nickname): accessKeys = self.server.keyShortcuts[nickname] - customSubmitText = getConfigParam(base_dir, 'customSubmitText') + customSubmitText = get_config_param(base_dir, 'customSubmitText') conversationId = None msg = htmlNewPost(self.server.cssCache, False, self.server.translate, @@ -2833,7 +2833,7 @@ class PubServer(BaseHTTPRequestHandler): if self.server.keyShortcuts.get(nickname): accessKeys = self.server.keyShortcuts[nickname] - customSubmitText = getConfigParam(base_dir, 'customSubmitText') + customSubmitText = get_config_param(base_dir, 'customSubmitText') conversationId = None msg = htmlNewPost(self.server.cssCache, False, self.server.translate, @@ -3862,7 +3862,7 @@ class PubServer(BaseHTTPRequestHandler): shareActor = removeShareConfirmParams.split('actor=')[1] if '&' in shareActor: shareActor = shareActor.split('&')[0] - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') adminActor = \ local_actor_url(http_prefix, adminNickname, domain_full) actor = originPathStr @@ -3929,7 +3929,7 @@ class PubServer(BaseHTTPRequestHandler): shareActor = removeShareConfirmParams.split('actor=')[1] if '&' in shareActor: shareActor = shareActor.split('&')[0] - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') adminActor = \ local_actor_url(http_prefix, adminNickname, domain_full) actor = originPathStr @@ -4154,7 +4154,7 @@ class PubServer(BaseHTTPRequestHandler): linksFilename) adminNickname = \ - getConfigParam(base_dir, 'admin') + get_config_param(base_dir, 'admin') if nickname == adminNickname: if fields.get('editedAbout'): aboutStr = fields['editedAbout'] @@ -4733,7 +4733,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.POSTbusy = False return - adminNickname = getConfigParam(self.server.base_dir, 'admin') + adminNickname = get_config_param(self.server.base_dir, 'admin') # get the various avatar, banner and background images actorChanged = True @@ -5024,20 +5024,20 @@ class PubServer(BaseHTTPRequestHandler): self.server.iconsCache = {} self.server.fontsCache = {} self.server.show_publish_as_icon = \ - getConfigParam(self.server.base_dir, - 'show_publish_as_icon') + get_config_param(self.server.base_dir, + 'show_publish_as_icon') self.server.full_width_tl_button_header = \ - getConfigParam(self.server.base_dir, - 'full_width_tl_button_header') + get_config_param(self.server.base_dir, + 'full_width_tl_button_header') self.server.icons_as_buttons = \ - getConfigParam(self.server.base_dir, - 'icons_as_buttons') + get_config_param(self.server.base_dir, + 'icons_as_buttons') self.server.rss_icon_at_top = \ - getConfigParam(self.server.base_dir, - 'rss_icon_at_top') + get_config_param(self.server.base_dir, + 'rss_icon_at_top') self.server.publish_button_at_top = \ - getConfigParam(self.server.base_dir, - 'publish_button_at_top') + get_config_param(self.server.base_dir, + 'publish_button_at_top') setNewsAvatar(base_dir, fields['themeDropdown'], http_prefix, @@ -5131,7 +5131,7 @@ class PubServer(BaseHTTPRequestHandler): # change instance title if fields.get('instanceTitle'): currInstanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') if fields['instanceTitle'] != currInstanceTitle: setConfigParam(base_dir, 'instanceTitle', fields['instanceTitle']) @@ -5181,7 +5181,7 @@ class PubServer(BaseHTTPRequestHandler): # change custom post submit button text currCustomSubmitText = \ - getConfigParam(base_dir, 'customSubmitText') + get_config_param(base_dir, 'customSubmitText') if fields.get('customSubmitText'): if fields['customSubmitText'] != \ currCustomSubmitText: @@ -5196,8 +5196,8 @@ class PubServer(BaseHTTPRequestHandler): # libretranslate URL currLibretranslateUrl = \ - getConfigParam(base_dir, - 'libretranslateUrl') + get_config_param(base_dir, + 'libretranslateUrl') if fields.get('libretranslateUrl'): if fields['libretranslateUrl'] != \ currLibretranslateUrl: @@ -5214,8 +5214,8 @@ class PubServer(BaseHTTPRequestHandler): # libretranslate API Key currLibretranslateApiKey = \ - getConfigParam(base_dir, - 'libretranslateApiKey') + get_config_param(base_dir, + 'libretranslateApiKey') if fields.get('libretranslateApiKey'): if fields['libretranslateApiKey'] != \ currLibretranslateApiKey: @@ -5248,8 +5248,8 @@ class PubServer(BaseHTTPRequestHandler): # change instance short description currInstanceDescriptionShort = \ - getConfigParam(base_dir, - 'instanceDescriptionShort') + get_config_param(base_dir, + 'instanceDescriptionShort') if fields.get('instanceDescriptionShort'): if fields['instanceDescriptionShort'] != \ currInstanceDescriptionShort: @@ -5264,7 +5264,7 @@ class PubServer(BaseHTTPRequestHandler): # change instance description currInstanceDescription = \ - getConfigParam(base_dir, 'instanceDescription') + get_config_param(base_dir, 'instanceDescription') if fields.get('instanceDescription'): if fields['instanceDescription'] != \ currInstanceDescription: @@ -5546,7 +5546,7 @@ class PubServer(BaseHTTPRequestHandler): redirectPath = 'previewAvatar' adminNickname = \ - getConfigParam(base_dir, 'admin') + get_config_param(base_dir, 'admin') if adminNickname: # whether to require jsonld signatures @@ -5585,7 +5585,7 @@ class PubServer(BaseHTTPRequestHandler): if fields['broch_mode'] == 'on': broch_mode = True currBrochMode = \ - getConfigParam(base_dir, "broch_mode") + get_config_param(base_dir, "broch_mode") if broch_mode != currBrochMode: setBrochMode(self.server.base_dir, self.server.domain_full, @@ -5598,8 +5598,8 @@ class PubServer(BaseHTTPRequestHandler): fed_domains_variable = \ "shared_items_federated_domains" fed_domains_str = \ - getConfigParam(base_dir, - fed_domains_variable) + get_config_param(base_dir, + fed_domains_variable) if not fed_domains_str: fed_domains_str = '' sharedItemsFormStr = '' @@ -5964,21 +5964,21 @@ class PubServer(BaseHTTPRequestHandler): self.server.iconsCache = {} self.server.fontsCache = {} self.server.show_publish_as_icon = \ - getConfigParam(base_dir, - 'show_publish_as_icon') + get_config_param(base_dir, + 'show_publish_as_icon') self.server.full_width_tl_button_header = \ - getConfigParam(base_dir, - 'fullWidthTimeline' + - 'ButtonHeader') + get_config_param(base_dir, + 'fullWidthTimeline' + + 'ButtonHeader') self.server.icons_as_buttons = \ - getConfigParam(base_dir, - 'icons_as_buttons') + get_config_param(base_dir, + 'icons_as_buttons') self.server.rss_icon_at_top = \ - getConfigParam(base_dir, - 'rss_icon_at_top') + get_config_param(base_dir, + 'rss_icon_at_top') self.server.publish_button_at_top = \ - getConfigParam(base_dir, - 'publish_button_at_top') + get_config_param(base_dir, + 'publish_button_at_top') # only receive DMs from accounts you follow followDMsFilename = \ @@ -6212,7 +6212,7 @@ class PubServer(BaseHTTPRequestHandler): if path.startswith('/users/' + adminNickname + '/') or \ isArtist(base_dir, nickname): currLowBandwidth = \ - getConfigParam(base_dir, 'low_bandwidth') + get_config_param(base_dir, 'low_bandwidth') low_bandwidth = False if fields.get('low_bandwidth'): if fields['low_bandwidth'] == 'on': @@ -6682,7 +6682,7 @@ class PubServer(BaseHTTPRequestHandler): favType = 'image/avif' favFilename = favFilename.split('.')[0] + '.avif' if not self.server.theme_name: - self.theme_name = getConfigParam(base_dir, 'theme') + self.theme_name = get_config_param(base_dir, 'theme') if not self.server.theme_name: self.server.theme_name = 'default' # custom favicon @@ -12964,7 +12964,7 @@ class PubServer(BaseHTTPRequestHandler): if self.server.keyShortcuts.get(nickname): accessKeys = self.server.keyShortcuts[nickname] - customSubmitText = getConfigParam(base_dir, 'customSubmitText') + customSubmitText = get_config_param(base_dir, 'customSubmitText') post_json_object = None if inReplyToUrl: @@ -16552,7 +16552,7 @@ class PubServer(BaseHTTPRequestHandler): return -1 submitText = self.server.translate['Submit'] customSubmitText = \ - getConfigParam(self.server.base_dir, 'customSubmitText') + get_config_param(self.server.base_dir, 'customSubmitText') if customSubmitText: submitText = customSubmitText if fields.get('submitPost'): @@ -17965,8 +17965,9 @@ class PubServer(BaseHTTPRequestHandler): if self.server.debug: print('SharesCatalog header: ' + self.headers['SharesCatalog']) if not self.server.shared_items_federated_domains: - siDomainsStr = getConfigParam(self.server.base_dir, - 'shared_items_federated_domains') + siDomainsStr = \ + get_config_param(self.server.base_dir, + 'shared_items_federated_domains') if siDomainsStr: if self.server.debug: print('Loading shared items federated domains list') @@ -18818,11 +18819,11 @@ def runDaemon(content_license_url: str, if lists_enabled: httpd.lists_enabled = lists_enabled else: - httpd.lists_enabled = getConfigParam(base_dir, "lists_enabled") + httpd.lists_enabled = get_config_param(base_dir, "lists_enabled") httpd.cw_lists = loadCWLists(base_dir, True) # set the avatar for the news account - httpd.theme_name = getConfigParam(base_dir, 'theme') + httpd.theme_name = get_config_param(base_dir, 'theme') if not httpd.theme_name: httpd.theme_name = 'default' if isNewsThemeName(base_dir, httpd.theme_name): diff --git a/epicyon.py b/epicyon.py index 8d15dc71e..306e41460 100644 --- a/epicyon.py +++ b/epicyon.py @@ -70,7 +70,7 @@ from utils import getPortFromDomain from utils import has_users_path from utils import get_full_domain from utils import setConfigParam -from utils import getConfigParam +from utils import get_config_param from utils import getDomainFromActor from utils import getNicknameFromActor from utils import followPerson @@ -694,7 +694,7 @@ if args.libretranslateApiKey: if args.posts: if not args.domain: - originDomain = getConfigParam(base_dir, 'domain') + originDomain = get_config_param(base_dir, 'domain') else: originDomain = args.domain if debug: @@ -763,7 +763,7 @@ if args.postDomains: args.language = 'en' signing_priv_key_pem = None if not args.domain: - originDomain = getConfigParam(base_dir, 'domain') + originDomain = get_config_param(base_dir, 'domain') else: originDomain = args.domain if args.secure_mode: @@ -882,7 +882,7 @@ if args.socnet: if not args.language: args.language = 'en' if not args.domain: - args.domain = getConfigParam(base_dir, 'domain') + args.domain = get_config_param(base_dir, 'domain') domain = '' if args.domain: domain = args.domain @@ -904,7 +904,7 @@ if args.socnet: if args.postsraw: if not args.domain: - originDomain = getConfigParam(base_dir, 'domain') + originDomain = get_config_param(base_dir, 'domain') else: originDomain = args.domain if debug: @@ -939,7 +939,7 @@ if args.json: 'Accept': 'application/ld+json; profile="' + profileStr + '"' } if not args.domain: - args.domain = getConfigParam(base_dir, 'domain') + args.domain = get_config_param(base_dir, 'domain') domain = '' if args.domain: domain = args.domain @@ -963,7 +963,7 @@ if args.htmlpost: 'Accept': 'text/html; profile="' + profileStr + '"' } if not args.domain: - args.domain = getConfigParam(base_dir, 'domain') + args.domain = get_config_param(base_dir, 'domain') domain = '' if args.domain: domain = args.domain @@ -992,13 +992,13 @@ if not os.path.isdir(base_dir + '/cache/announce'): os.mkdir(base_dir + '/cache/announce') # set the theme in config.json -theme_name = getConfigParam(base_dir, 'theme') +theme_name = get_config_param(base_dir, 'theme') if not theme_name: setConfigParam(base_dir, 'theme', 'default') theme_name = 'default' if not args.mediainstance: - media_instance = getConfigParam(base_dir, 'media_instance') + media_instance = get_config_param(base_dir, 'media_instance') if media_instance is not None: args.mediainstance = media_instance if args.mediainstance: @@ -1006,7 +1006,7 @@ if not args.mediainstance: args.newsinstance = False if not args.newsinstance: - news_instance = getConfigParam(base_dir, 'news_instance') + news_instance = get_config_param(base_dir, 'news_instance') if news_instance is not None: args.newsinstance = news_instance if args.newsinstance: @@ -1014,7 +1014,7 @@ if not args.newsinstance: args.mediainstance = False if not args.blogsinstance: - blogs_instance = getConfigParam(base_dir, 'blogs_instance') + blogs_instance = get_config_param(base_dir, 'blogs_instance') if blogs_instance is not None: args.blogsinstance = blogs_instance if args.blogsinstance: @@ -1022,18 +1022,18 @@ if not args.blogsinstance: args.newsinstance = False # set the instance title in config.json -title = getConfigParam(base_dir, 'instanceTitle') +title = get_config_param(base_dir, 'instanceTitle') if not title: setConfigParam(base_dir, 'instanceTitle', 'Epicyon') # set the instance description in config.json -descFull = getConfigParam(base_dir, 'instanceDescription') +descFull = get_config_param(base_dir, 'instanceDescription') if not descFull: setConfigParam(base_dir, 'instanceDescription', 'Just another ActivityPub server') # set the short instance description in config.json -descShort = getConfigParam(base_dir, 'instanceDescriptionShort') +descShort = get_config_param(base_dir, 'instanceDescriptionShort') if not descShort: setConfigParam(base_dir, 'instanceDescriptionShort', 'Just another ActivityPub server') @@ -1069,7 +1069,7 @@ if args.i2p_domain: setConfigParam(base_dir, 'i2p_domain', i2p_domain) if not args.language: - languageCode = getConfigParam(base_dir, 'language') + languageCode = get_config_param(base_dir, 'language') if languageCode: args.language = languageCode else: @@ -1077,7 +1077,7 @@ if not args.language: # maximum number of new registrations if not args.maxRegistrations: - maxRegistrations = getConfigParam(base_dir, 'maxRegistrations') + maxRegistrations = get_config_param(base_dir, 'maxRegistrations') if not maxRegistrations: maxRegistrations = 10 setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations)) @@ -1088,7 +1088,7 @@ else: setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations)) # if this is the initial run then allow new registrations -if not getConfigParam(base_dir, 'registration'): +if not get_config_param(base_dir, 'registration'): if args.registration.lower() == 'open': setConfigParam(base_dir, 'registration', 'open') setConfigParam(base_dir, 'maxRegistrations', str(maxRegistrations)) @@ -1100,35 +1100,35 @@ if args.resetregistrations: print('Number of new registrations reset to ' + str(maxRegistrations)) # unique ID for the instance -instance_id = getConfigParam(base_dir, 'instance_id') +instance_id = get_config_param(base_dir, 'instance_id') if not instance_id: instance_id = createPassword(32) setConfigParam(base_dir, 'instance_id', instance_id) print('Instance ID: ' + instance_id) # get domain name from configuration -configDomain = getConfigParam(base_dir, 'domain') +configDomain = get_config_param(base_dir, 'domain') if configDomain: domain = configDomain else: domain = 'localhost' # get onion domain name from configuration -configOnionDomain = getConfigParam(base_dir, 'onion') +configOnionDomain = get_config_param(base_dir, 'onion') if configOnionDomain: onion_domain = configOnionDomain else: onion_domain = None # get i2p domain name from configuration -configi2p_domain = getConfigParam(base_dir, 'i2p_domain') +configi2p_domain = get_config_param(base_dir, 'i2p_domain') if configi2p_domain: i2p_domain = configi2p_domain else: i2p_domain = None # get port number from configuration -configPort = getConfigParam(base_dir, 'port') +configPort = get_config_param(base_dir, 'port') if configPort: port = configPort else: @@ -1138,7 +1138,7 @@ else: else: port = 443 -configProxyPort = getConfigParam(base_dir, 'proxy_port') +configProxyPort = get_config_param(base_dir, 'proxy_port') if configProxyPort: proxy_port = configProxyPort else: @@ -1162,7 +1162,7 @@ if args.federation_list: federation_list = args.federation_list.copy() setConfigParam(base_dir, 'federation_list', federation_list) else: - configFederationList = getConfigParam(base_dir, 'federation_list') + configFederationList = get_config_param(base_dir, 'federation_list') if configFederationList: federation_list = configFederationList @@ -1187,7 +1187,7 @@ if args.approve: cached_webfingers = {} person_cache = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1215,7 +1215,7 @@ if args.deny: cached_webfingers = {} person_cache = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1308,7 +1308,7 @@ if args.message: followersOnly = False isArticle = False if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1346,7 +1346,7 @@ if args.announce: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1390,7 +1390,7 @@ if args.box: elif args.gnunet: proxy_type = 'gnunet' if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1451,7 +1451,7 @@ if args.itemName: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1494,7 +1494,7 @@ if args.undoItemName: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1556,7 +1556,7 @@ if args.wantedItemName: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1599,7 +1599,7 @@ if args.undoWantedItemName: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1633,7 +1633,7 @@ if args.like: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1672,7 +1672,7 @@ if args.react: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1705,7 +1705,7 @@ if args.undolike: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1745,7 +1745,7 @@ if args.undoreact: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1779,7 +1779,7 @@ if args.bookmark: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1813,7 +1813,7 @@ if args.unbookmark: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1846,7 +1846,7 @@ if args.delete: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1891,7 +1891,7 @@ if args.follow: if args.follow.startswith('https'): followHttpPrefix = 'https' if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1937,7 +1937,7 @@ if args.unfollow: if args.follow.startswith('https'): followHttpPrefix = 'https' if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -1972,7 +1972,7 @@ if args.followingList: cached_webfingers = {} followHttpPrefix = http_prefix if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2005,7 +2005,7 @@ if args.followersList: cached_webfingers = {} followHttpPrefix = http_prefix if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2039,7 +2039,7 @@ if args.followRequestsList: cached_webfingers = {} followHttpPrefix = http_prefix if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2091,7 +2091,7 @@ if args.migrations: port = 443 session = createSession(proxy_type) if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2106,7 +2106,7 @@ if args.migrations: if args.actor: if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = getInstanceActorKey(base_dir, domain) if debug: print('base_dir: ' + str(base_dir)) @@ -2260,11 +2260,11 @@ if args.addaccount: domain = args.addaccount.split('@')[1] else: nickname = args.addaccount - if not args.domain or not getConfigParam(base_dir, 'domain'): + if not args.domain or not get_config_param(base_dir, 'domain'): print('Use the --domain option to set the domain name') sys.exit() - configuredDomain = getConfigParam(base_dir, 'domain') + configuredDomain = get_config_param(base_dir, 'domain') if configuredDomain: if domain != configuredDomain: print('The account domain is expected to be ' + configuredDomain) @@ -2308,7 +2308,7 @@ if args.addgroup: domain = args.addgroup.split('@')[1] else: nickname = args.addgroup - if not args.domain or not getConfigParam(base_dir, 'domain'): + if not args.domain or not get_config_param(base_dir, 'domain'): print('Use the --domain option to set the domain name') sys.exit() if nickname.startswith('!'): @@ -2350,15 +2350,15 @@ if args.rmaccount: domain = args.rmaccount.split('@')[1] else: nickname = args.rmaccount - if not args.domain or not getConfigParam(base_dir, 'domain'): + if not args.domain or not get_config_param(base_dir, 'domain'): print('Use the --domain option to set the domain name') sys.exit() if args.domain: domain = args.domain else: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') - configuredDomain = getConfigParam(base_dir, 'domain') + configuredDomain = get_config_param(base_dir, 'domain') if configuredDomain: if domain != configuredDomain: print('The account domain is expected to be ' + configuredDomain) @@ -2384,7 +2384,7 @@ if args.activate: domain = args.activate.split('@')[1] else: nickname = args.activate - if not args.domain or not getConfigParam(base_dir, 'domain'): + if not args.domain or not get_config_param(base_dir, 'domain'): print('Use the --domain option to set the domain name') sys.exit() if activateAccount(base_dir, nickname, domain): @@ -2403,7 +2403,7 @@ if args.changepassword: domain = args.changepassword[0].split('@')[1] else: nickname = args.changepassword[0] - if not args.domain or not getConfigParam(base_dir, 'domain'): + if not args.domain or not get_config_param(base_dir, 'domain'): print('Use the --domain option to set the domain name') sys.exit() newPassword = args.changepassword[1] @@ -2499,7 +2499,7 @@ if args.skill: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2534,7 +2534,7 @@ if args.availability: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2614,7 +2614,7 @@ if args.shared_items_federated_domains: fed_domains_str) else: fed_domains_str = \ - getConfigParam(base_dir, 'shared_items_federated_domains') + get_config_param(base_dir, 'shared_items_federated_domains') if fed_domains_str: fed_domains_list = fed_domains_str.split(',') for sharedFederatedDomain in fed_domains_list: @@ -2648,7 +2648,7 @@ if args.block: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2680,7 +2680,7 @@ if args.mute: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2712,7 +2712,7 @@ if args.unmute: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -2756,7 +2756,7 @@ if args.unblock: person_cache = {} cached_webfingers = {} if not domain: - domain = getConfigParam(base_dir, 'domain') + domain = get_config_param(base_dir, 'domain') signing_priv_key_pem = None if args.secure_mode: signing_priv_key_pem = getInstanceActorKey(base_dir, domain) @@ -3001,11 +3001,11 @@ if args.testdata: if args.max_mentions < 4: args.max_mentions = 4 -registration = getConfigParam(base_dir, 'registration') +registration = get_config_param(base_dir, 'registration') if not registration: registration = False -minimumvotes = getConfigParam(base_dir, 'minvotes') +minimumvotes = get_config_param(base_dir, 'minvotes') if minimumvotes: args.minimumvotes = int(minimumvotes) @@ -3014,127 +3014,127 @@ if args.content_license_url: content_license_url = args.content_license_url setConfigParam(base_dir, 'content_license_url', content_license_url) else: - content_license_url = getConfigParam(base_dir, 'content_license_url') + content_license_url = get_config_param(base_dir, 'content_license_url') -votingtime = getConfigParam(base_dir, 'votingtime') +votingtime = get_config_param(base_dir, 'votingtime') if votingtime: args.votingtime = votingtime # only show the date at the bottom of posts -dateonly = getConfigParam(base_dir, 'dateonly') +dateonly = get_config_param(base_dir, 'dateonly') if dateonly: args.dateonly = dateonly # set the maximum number of newswire posts per account or rss feed max_newswire_postsPerSource = \ - getConfigParam(base_dir, 'max_newswire_postsPerSource') + get_config_param(base_dir, 'max_newswire_postsPerSource') if max_newswire_postsPerSource: args.max_newswire_postsPerSource = int(max_newswire_postsPerSource) # set the maximum number of newswire posts appearing in the right column max_newswire_posts = \ - getConfigParam(base_dir, 'max_newswire_posts') + get_config_param(base_dir, 'max_newswire_posts') if max_newswire_posts: args.max_newswire_posts = int(max_newswire_posts) # set the maximum size of a newswire rss/atom feed in Kilobytes max_newswire_feed_size_kb = \ - getConfigParam(base_dir, 'max_newswire_feed_size_kb') + get_config_param(base_dir, 'max_newswire_feed_size_kb') if max_newswire_feed_size_kb: args.max_newswire_feed_size_kb = int(max_newswire_feed_size_kb) max_mirrored_articles = \ - getConfigParam(base_dir, 'max_mirrored_articles') + get_config_param(base_dir, 'max_mirrored_articles') if max_mirrored_articles is not None: args.max_mirrored_articles = int(max_mirrored_articles) max_news_posts = \ - getConfigParam(base_dir, 'max_news_posts') + get_config_param(base_dir, 'max_news_posts') if max_news_posts is not None: args.max_news_posts = int(max_news_posts) max_followers = \ - getConfigParam(base_dir, 'max_followers') + get_config_param(base_dir, 'max_followers') if max_followers is not None: args.max_followers = int(max_followers) max_feed_item_size_kb = \ - getConfigParam(base_dir, 'max_feed_item_size_kb') + get_config_param(base_dir, 'max_feed_item_size_kb') if max_feed_item_size_kb is not None: args.max_feed_item_size_kb = int(max_feed_item_size_kb) dormant_months = \ - getConfigParam(base_dir, 'dormant_months') + get_config_param(base_dir, 'dormant_months') if dormant_months is not None: args.dormant_months = int(dormant_months) send_threads_timeout_mins = \ - getConfigParam(base_dir, 'send_threads_timeout_mins') + get_config_param(base_dir, 'send_threads_timeout_mins') if send_threads_timeout_mins is not None: args.send_threads_timeout_mins = int(send_threads_timeout_mins) max_like_count = \ - getConfigParam(base_dir, 'max_like_count') + get_config_param(base_dir, 'max_like_count') if max_like_count is not None: args.max_like_count = int(max_like_count) show_publish_as_icon = \ - getConfigParam(base_dir, 'show_publish_as_icon') + get_config_param(base_dir, 'show_publish_as_icon') if show_publish_as_icon is not None: args.show_publish_as_icon = bool(show_publish_as_icon) icons_as_buttons = \ - getConfigParam(base_dir, 'icons_as_buttons') + get_config_param(base_dir, 'icons_as_buttons') if icons_as_buttons is not None: args.icons_as_buttons = bool(icons_as_buttons) rss_icon_at_top = \ - getConfigParam(base_dir, 'rss_icon_at_top') + get_config_param(base_dir, 'rss_icon_at_top') if rss_icon_at_top is not None: args.rss_icon_at_top = bool(rss_icon_at_top) publish_button_at_top = \ - getConfigParam(base_dir, 'publish_button_at_top') + get_config_param(base_dir, 'publish_button_at_top') if publish_button_at_top is not None: args.publish_button_at_top = bool(publish_button_at_top) full_width_tl_button_header = \ - getConfigParam(base_dir, 'full_width_tl_button_header') + get_config_param(base_dir, 'full_width_tl_button_header') if full_width_tl_button_header is not None: args.full_width_tl_button_header = bool(full_width_tl_button_header) allow_local_network_access = \ - getConfigParam(base_dir, 'allow_local_network_access') + get_config_param(base_dir, 'allow_local_network_access') if allow_local_network_access is not None: args.allow_local_network_access = bool(allow_local_network_access) verify_all_signatures = \ - getConfigParam(base_dir, 'verify_all_signatures') + get_config_param(base_dir, 'verify_all_signatures') if verify_all_signatures is not None: args.verify_all_signatures = bool(verify_all_signatures) broch_mode = \ - getConfigParam(base_dir, 'broch_mode') + get_config_param(base_dir, 'broch_mode') if broch_mode is not None: args.broch_mode = bool(broch_mode) log_login_failures = \ - getConfigParam(base_dir, 'log_login_failures') + get_config_param(base_dir, 'log_login_failures') if log_login_failures is not None: args.log_login_failures = bool(log_login_failures) show_node_info_accounts = \ - getConfigParam(base_dir, 'show_node_info_accounts') + get_config_param(base_dir, 'show_node_info_accounts') if show_node_info_accounts is not None: args.show_node_info_accounts = bool(show_node_info_accounts) show_node_info_version = \ - getConfigParam(base_dir, 'show_node_info_version') + get_config_param(base_dir, 'show_node_info_version') if show_node_info_version is not None: args.show_node_info_version = bool(show_node_info_version) low_bandwidth = \ - getConfigParam(base_dir, 'low_bandwidth') + get_config_param(base_dir, 'low_bandwidth') if low_bandwidth is not None: args.low_bandwidth = bool(low_bandwidth) @@ -3144,7 +3144,7 @@ if args.userAgentBlocks: setConfigParam(base_dir, 'user_agents_blocked', user_agents_blockedStr) else: user_agents_blockedStr = \ - getConfigParam(base_dir, 'user_agents_blocked') + get_config_param(base_dir, 'user_agents_blocked') if user_agents_blockedStr: agentBlocksList = user_agents_blockedStr.split(',') for agentBlockStr in agentBlocksList: @@ -3155,14 +3155,14 @@ if args.lists_enabled: lists_enabled = args.lists_enabled setConfigParam(base_dir, 'lists_enabled', lists_enabled) else: - lists_enabled = getConfigParam(base_dir, 'lists_enabled') + lists_enabled = get_config_param(base_dir, 'lists_enabled') city = \ - getConfigParam(base_dir, 'city') + get_config_param(base_dir, 'city') if city is not None: args.city = city -YTDomain = getConfigParam(base_dir, 'youtubedomain') +YTDomain = get_config_param(base_dir, 'youtubedomain') if YTDomain: if '://' in YTDomain: YTDomain = YTDomain.split('://')[1] @@ -3171,7 +3171,7 @@ if YTDomain: if '.' in YTDomain: args.yt_replace_domain = YTDomain -twitterDomain = getConfigParam(base_dir, 'twitterdomain') +twitterDomain = get_config_param(base_dir, 'twitterdomain') if twitterDomain: if '://' in twitterDomain: twitterDomain = twitterDomain.split('://')[1] @@ -3187,7 +3187,7 @@ if setTheme(base_dir, theme_name, domain, # whether new registrations are open or closed if args.registration: if args.registration.lower() == 'open': - registration = getConfigParam(base_dir, 'registration') + registration = get_config_param(base_dir, 'registration') if not registration: setConfigParam(base_dir, 'registrationsRemaining', str(maxRegistrations)) @@ -3201,7 +3201,7 @@ if args.registration: setConfigParam(base_dir, 'registration', 'closed') print('New registrations closed') -defaultCurrency = getConfigParam(base_dir, 'defaultCurrency') +defaultCurrency = get_config_param(base_dir, 'defaultCurrency') if not defaultCurrency: setConfigParam(base_dir, 'defaultCurrency', 'EUR') if args.defaultCurrency: diff --git a/fitnessFunctions.py b/fitnessFunctions.py index 06882e886..35fec3735 100644 --- a/fitnessFunctions.py +++ b/fitnessFunctions.py @@ -11,7 +11,7 @@ import os import time from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlFooter -from utils import getConfigParam +from utils import get_config_param from utils import saveJson @@ -75,7 +75,7 @@ def htmlWatchPointsGraph(base_dir: str, fitness: {}, fitnessId: str, cssFilename = base_dir + '/graph.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) htmlStr += \ '\n' + \ diff --git a/inbox.py b/inbox.py index fd18a40be..7ce7935f8 100644 --- a/inbox.py +++ b/inbox.py @@ -35,7 +35,7 @@ from utils import getPortFromDomain from utils import has_object_dict from utils import dmAllowedFromDomain from utils import isRecentPost -from utils import getConfigParam +from utils import get_config_param from utils import has_users_path from utils import valid_post_date from utils import get_full_domain @@ -303,8 +303,8 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, max_recent_posts: int, boxname = 'inbox' notDM = not isDM(post_json_object) - yt_replace_domain = getConfigParam(base_dir, 'youtubedomain') - twitter_replacement_domain = getConfigParam(base_dir, 'twitterdomain') + yt_replace_domain = get_config_param(base_dir, 'youtubedomain') + twitter_replacement_domain = get_config_param(base_dir, 'twitterdomain') individualPostAsHtml(signing_priv_key_pem, True, recentPostsCache, max_recent_posts, translate, pageNumber, @@ -2631,7 +2631,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int, sharedItemFederationTokens = {} shared_items_federated_domains = [] shared_items_federated_domainsStr = \ - getConfigParam(base_dir, 'shared_items_federated_domains') + get_config_param(base_dir, 'shared_items_federated_domains') if shared_items_federated_domainsStr: siFederatedDomainsList = \ shared_items_federated_domainsStr.split(',') @@ -4207,7 +4207,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int, 'accounts': {} } # also check if the json signature enforcement has changed - verifyAllSigs = getConfigParam(base_dir, "verify_all_signatures") + verifyAllSigs = get_config_param(base_dir, "verify_all_signatures") if verifyAllSigs is not None: verify_all_signatures = verifyAllSigs # change the last time that this was done @@ -4489,8 +4489,8 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int, if not os.path.isfile(sharedInboxPostFilename): saveJson(queueJson['post'], sharedInboxPostFilename) - lists_enabled = getConfigParam(base_dir, "lists_enabled") - content_license_url = getConfigParam(base_dir, "content_license_url") + lists_enabled = get_config_param(base_dir, "lists_enabled") + content_license_url = get_config_param(base_dir, "content_license_url") # for posts addressed to specific accounts for handle, capsId in recipientsDict.items(): diff --git a/languages.py b/languages.py index 0524ccd15..918f364f8 100644 --- a/languages.py +++ b/languages.py @@ -13,7 +13,7 @@ from urllib import request, parse from utils import get_actor_languages_list from utils import removeHtml from utils import has_object_dict -from utils import getConfigParam +from utils import get_config_param from utils import local_actor_url from cache import getPersonFromCache @@ -118,9 +118,10 @@ def understoodPostLanguage(base_dir: str, nickname: str, domain: str, if msgObject['contentMap'].get(lang): return True # is the language for this post supported by libretranslate? - libretranslateUrl = getConfigParam(base_dir, "libretranslateUrl") + libretranslateUrl = get_config_param(base_dir, "libretranslateUrl") if libretranslateUrl: - libretranslateApiKey = getConfigParam(base_dir, "libretranslateApiKey") + libretranslateApiKey = \ + get_config_param(base_dir, "libretranslateApiKey") lang_list = \ libretranslateLanguages(libretranslateUrl, libretranslateApiKey) for lang in lang_list: @@ -287,10 +288,10 @@ def autoTranslatePost(base_dir: str, post_json_object: {}, return '' # is the language for this post supported by libretranslate? - libretranslateUrl = getConfigParam(base_dir, "libretranslateUrl") + libretranslateUrl = get_config_param(base_dir, "libretranslateUrl") if not libretranslateUrl: return '' - libretranslateApiKey = getConfigParam(base_dir, "libretranslateApiKey") + libretranslateApiKey = get_config_param(base_dir, "libretranslateApiKey") lang_list = \ libretranslateLanguages(libretranslateUrl, libretranslateApiKey) for lang in lang_list: diff --git a/mastoapiv1.py b/mastoapiv1.py index 6d21c3100..78048af34 100644 --- a/mastoapiv1.py +++ b/mastoapiv1.py @@ -9,7 +9,7 @@ __module_group__ = "API" import os from utils import loadJson -from utils import getConfigParam +from utils import get_config_param from utils import acct_dir from metadata import metaDataInstance @@ -196,17 +196,16 @@ def mastoApiV1Response(path: str, callingDomain: str, sendJsonStr = \ 'masto API custom emojis sent ' + path + callingInfo - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if adminNickname and path == '/api/v1/instance': instanceDescriptionShort = \ - getConfigParam(base_dir, - 'instanceDescriptionShort') + get_config_param(base_dir, 'instanceDescriptionShort') if not instanceDescriptionShort: instanceDescriptionShort = \ translate['Yet another Epicyon Instance'] - instanceDescription = getConfigParam(base_dir, - 'instanceDescription') - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceDescription = \ + get_config_param(base_dir, 'instanceDescription') + instanceTitle = get_config_param(base_dir, 'instanceTitle') if callingDomain.endswith('.onion') and onion_domain: domain_full = onion_domain diff --git a/person.py b/person.py index bacbe011e..f934a2a2e 100644 --- a/person.py +++ b/person.py @@ -49,7 +49,7 @@ from utils import validNickname from utils import loadJson from utils import saveJson from utils import setConfigParam -from utils import getConfigParam +from utils import get_config_param from utils import refresh_newswire from utils import getProtocolPrefixes from utils import has_users_path @@ -605,7 +605,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int, # remaining registrations counter if nickname != 'news': remainingConfigExists = \ - getConfigParam(base_dir, 'registrationsRemaining') + get_config_param(base_dir, 'registrationsRemaining') if remainingConfigExists: registrationsRemaining = int(remainingConfigExists) if registrationsRemaining <= 0: @@ -625,7 +625,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int, manual_follower, group_account, password) - if not getConfigParam(base_dir, 'admin'): + if not get_config_param(base_dir, 'admin'): if nickname != 'news': # print(nickname+' becomes the instance admin and a moderator') setConfigParam(base_dir, 'admin', nickname) @@ -668,7 +668,7 @@ def createPerson(base_dir: str, nickname: str, domain: str, port: int, except OSError: print('EX: unable to write ' + notifyReactionsFilename) - theme = getConfigParam(base_dir, 'theme') + theme = get_config_param(base_dir, 'theme') if not theme: theme = 'default' @@ -822,7 +822,7 @@ def personUpgradeActor(base_dir: str, personJson: {}, # roles are configured rolesList = getActorRolesList(personJson) if not rolesList: - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if personJson['id'].endswith('/users/' + adminName): rolesList = ["admin", "moderator", "editor"] setRolesFromList(personJson, rolesList) @@ -1060,7 +1060,7 @@ def suspendAccount(base_dir: str, nickname: str, domain: str) -> None: """Suspends the given account """ # Don't suspend the admin - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if not adminNickname: return if nickname == adminNickname: @@ -1118,7 +1118,7 @@ def canRemovePost(base_dir: str, nickname: str, domain_full = get_full_domain(domain, port) # is the post by the admin? - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if not adminNickname: return False if domain_full + '/users/' + adminNickname + '/' in postId: @@ -1176,7 +1176,7 @@ def removeAccount(base_dir: str, nickname: str, """Removes an account """ # Don't remove the admin - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if not adminNickname: return False if nickname == adminNickname: diff --git a/posts.py b/posts.py index 6f213e090..fe55feba4 100644 --- a/posts.py +++ b/posts.py @@ -61,7 +61,7 @@ from utils import validNickname from utils import locatePost from utils import loadJson from utils import saveJson -from utils import getConfigParam +from utils import get_config_param from utils import locateNewsVotes from utils import locateNewsArrival from utils import votesOnNewswireItem @@ -96,7 +96,7 @@ def isModerator(base_dir: str, nickname: str) -> bool: moderatorsFile = base_dir + '/accounts/moderators.txt' if not os.path.isfile(moderatorsFile): - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -106,7 +106,7 @@ def isModerator(base_dir: str, nickname: str) -> bool: with open(moderatorsFile, 'r') as f: lines = f.readlines() if len(lines) == 0: - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -2153,7 +2153,7 @@ def createReportPost(base_dir: str, moderatorsList.append(moderatorActor) if len(moderatorsList) == 0: # if there are no moderators then the admin becomes the moderator - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if adminNickname: localActor = \ local_actor_url(http_prefix, adminNickname, domain_full) diff --git a/shares.py b/shares.py index 865a3541a..037348b79 100644 --- a/shares.py +++ b/shares.py @@ -25,7 +25,7 @@ from session import createSession from utils import hasObjectStringType from utils import dateStringToSeconds from utils import dateSecondsToString -from utils import getConfigParam +from utils import get_config_param from utils import get_full_domain from utils import validNickname from utils import loadJson @@ -1711,7 +1711,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str, _generateNextSharesTokenUpdate(base_dir, minDays, maxDays) while True: shared_items_federated_domainsStr = \ - getConfigParam(base_dir, 'shared_items_federated_domains') + get_config_param(base_dir, 'shared_items_federated_domains') if not shared_items_federated_domainsStr: time.sleep(fileCheckIntervalSec) continue diff --git a/utils.py b/utils.py index 4100cb952..4c92d71cd 100644 --- a/utils.py +++ b/utils.py @@ -292,7 +292,7 @@ def is_editor(base_dir: str, nickname: str) -> bool: editorsFile = base_dir + '/accounts/editors.txt' if not os.path.isfile(editorsFile): - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -302,7 +302,7 @@ def is_editor(base_dir: str, nickname: str) -> bool: with open(editorsFile, 'r') as f: lines = f.readlines() if len(lines) == 0: - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -320,7 +320,7 @@ def isArtist(base_dir: str, nickname: str) -> bool: artistsFile = base_dir + '/accounts/artists.txt' if not os.path.isfile(artistsFile): - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -330,7 +330,7 @@ def isArtist(base_dir: str, nickname: str) -> bool: with open(artistsFile, 'r') as f: lines = f.readlines() if len(lines) == 0: - adminName = getConfigParam(base_dir, 'admin') + adminName = get_config_param(base_dir, 'admin') if not adminName: return False if adminName == nickname: @@ -516,7 +516,7 @@ def setConfigParam(base_dir: str, variableName: str, variableValue) -> None: saveJson(configJson, configFilename) -def getConfigParam(base_dir: str, variableName: str): +def get_config_param(base_dir: str, variableName: str): """Gets a configuration value """ _createConfig(base_dir) @@ -531,7 +531,7 @@ def getConfigParam(base_dir: str, variableName: str): def isSuspended(base_dir: str, nickname: str) -> bool: """Returns true if the given nickname is suspended """ - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if not adminNickname: return False if nickname == adminNickname: diff --git a/webapp_about.py b/webapp_about.py index 9490e1fc0..4cf75beff 100644 --- a/webapp_about.py +++ b/webapp_about.py @@ -9,7 +9,7 @@ __module_group__ = "Web Interface" import os from shutil import copyfile -from utils import getConfigParam +from utils import get_config_param from webapp_utils import htmlHeaderWithWebsiteMarkup from webapp_utils import htmlFooter from markdown import markdownToHtml @@ -20,7 +20,7 @@ def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str, system_language: str) -> str: """Show the about screen """ - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if not os.path.isfile(base_dir + '/accounts/about.md'): copyfile(base_dir + '/default_about.md', base_dir + '/accounts/about.md') @@ -41,7 +41,7 @@ def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') aboutForm = \ htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle, http_prefix, domain_full, diff --git a/webapp_accesskeys.py b/webapp_accesskeys.py index 82c81b6c0..db84b20fa 100644 --- a/webapp_accesskeys.py +++ b/webapp_accesskeys.py @@ -10,7 +10,7 @@ __module_group__ = "Accessibility" import os from utils import isAccountDir from utils import loadJson -from utils import getConfigParam +from utils import get_config_param from utils import acct_dir from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlFooter @@ -59,7 +59,7 @@ def htmlAccessKeys(cssCache: {}, base_dir: str, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') accessKeysForm = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) accessKeysForm += '
\n' diff --git a/webapp_calendar.py b/webapp_calendar.py index 5df262c7c..db2fdf14b 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -11,7 +11,7 @@ import os from datetime import datetime from datetime import date from utils import getDisplayName -from utils import getConfigParam +from utils import get_config_param from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost @@ -57,7 +57,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') deletePostStr = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) deletePostStr += \ @@ -119,7 +119,7 @@ def _htmlCalendarDay(person_cache: {}, cssCache: {}, translate: {}, if '/users/' in actor: calActor = '/users/' + actor.split('/users/')[1] - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceTitle = get_config_param(base_dir, 'instanceTitle') calendarStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) calendarStr += '
\n' calendarStr += '
\n' @@ -339,7 +339,7 @@ def htmlCalendar(person_cache: {}, cssCache: {}, translate: {}, calActor = '/users/' + actor.split('/users/')[1] instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') headerStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) # the main graphical calendar as a table diff --git a/webapp_column_left.py b/webapp_column_left.py index ed0cf7083..f41b05b6c 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -8,7 +8,7 @@ __status__ = "Production" __module_group__ = "Web Interface Columns" import os -from utils import getConfigParam +from utils import get_config_param from utils import getNicknameFromActor from utils import is_editor from utils import isArtist @@ -377,7 +377,7 @@ def htmlLinksMobile(cssCache: {}, base_dir: str, domain = removeDomainPort(domain_full) instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) bannerFile, bannerFilename = \ getBannerFile(base_dir, nickname, domain, theme) @@ -441,7 +441,7 @@ def htmlEditLinks(cssCache: {}, translate: {}, base_dir: str, path: str, getBannerFile(base_dir, nickname, domain, theme) instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') editLinksForm = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) @@ -495,7 +495,7 @@ def htmlEditLinks(cssCache: {}, translate: {}, base_dir: str, path: str, '' # the admin can edit terms of service and about text - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if adminNickname: if nickname == adminNickname: aboutFilename = base_dir + '/accounts/about.md' diff --git a/webapp_column_right.py b/webapp_column_right.py index cdf63a41c..f259d0b1d 100644 --- a/webapp_column_right.py +++ b/webapp_column_right.py @@ -19,7 +19,7 @@ from utils import loadJson from utils import votesOnNewswireItem from utils import getNicknameFromActor from utils import is_editor -from utils import getConfigParam +from utils import get_config_param from utils import removeDomainPort from utils import acct_dir from posts import isModerator @@ -364,7 +364,7 @@ def htmlCitations(base_dir: str, nickname: str, domain: str, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) # top banner @@ -479,7 +479,7 @@ def htmlNewswireMobile(cssCache: {}, base_dir: str, nickname: str, showPublishButton = editor instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) bannerFile, bannerFilename = \ @@ -546,7 +546,7 @@ def htmlEditNewswire(cssCache: {}, translate: {}, base_dir: str, path: str, getBannerFile(base_dir, nickname, domain, theme) instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') editNewswireForm = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) @@ -671,7 +671,7 @@ def htmlEditNewsPost(cssCache: {}, translate: {}, base_dir: str, path: str, cssFilename = base_dir + '/links.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') editNewsPostForm = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) editNewsPostForm += \ diff --git a/webapp_confirm.py b/webapp_confirm.py index ee0a49be6..c7a1617a9 100644 --- a/webapp_confirm.py +++ b/webapp_confirm.py @@ -14,7 +14,7 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from utils import locatePost from utils import loadJson -from utils import getConfigParam +from utils import get_config_param from utils import getAltPath from utils import acct_dir from webapp_utils import setCustomBackground @@ -61,7 +61,7 @@ def htmlConfirmDelete(cssCache: {}, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') deletePostStr = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) deletePostStr += \ @@ -138,7 +138,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str, if os.path.isfile(base_dir + '/follow.css'): cssFilename = base_dir + '/follow.css' - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceTitle = get_config_param(base_dir, 'instanceTitle') sharesStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) sharesStr += '
\n' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') profileStr = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) + \ profileStr + profileFooterStr + htmlFooter() diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index fb9f8d4a4..adf9d4ee3 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -10,7 +10,7 @@ __module_group__ = "Web Interface" import os from datetime import datetime from utils import getNicknameFromActor -from utils import getConfigParam +from utils import get_config_param from categories import getHashtagCategories from categories import getHashtagCategory from webapp_utils import setCustomBackground @@ -208,7 +208,7 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {}, cssFilename = base_dir + '/search.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) # show a banner above the search box diff --git a/webapp_login.py b/webapp_login.py index 1752a3254..e88a5d673 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -10,7 +10,7 @@ __module_group__ = "Web Interface" import os import time from shutil import copyfile -from utils import getConfigParam +from utils import get_config_param from utils import noOfAccounts from utils import getNicknameValidationPattern from webapp_utils import setCustomBackground @@ -119,8 +119,8 @@ def htmlLogin(cssCache: {}, translate: {}, # show the register button registerButtonStr = '' - if getConfigParam(base_dir, 'registration') == 'open': - if int(getConfigParam(base_dir, 'registrationsRemaining')) > 0: + if get_config_param(base_dir, 'registration') == 'open': + if int(get_config_param(base_dir, 'registrationsRemaining')) > 0: if accounts > 0: idx = 'Welcome. Please login or register a new account.' loginText = \ @@ -149,14 +149,14 @@ def htmlLogin(cssCache: {}, translate: {}, autocompletePasswordStr = 'autocomplete="off" value=""' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') loginForm = \ htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle, http_prefix, domain, system_language) nicknamePattern = getNicknameValidationPattern() - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceTitle = get_config_param(base_dir, 'instanceTitle') loginForm += \ '
\n' + \ '
\n' + \ diff --git a/webapp_moderation.py b/webapp_moderation.py index a8be72063..ad7dc3dcc 100644 --- a/webapp_moderation.py +++ b/webapp_moderation.py @@ -15,7 +15,7 @@ from utils import is_editor from utils import loadJson from utils import getNicknameFromActor from utils import getDomainFromActor -from utils import getConfigParam +from utils import get_config_param from utils import local_actor_url from posts import downloadFollowCollection from posts import getPublicPostInfo @@ -100,7 +100,7 @@ def htmlAccountInfo(cssCache: {}, translate: {}, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) searchNickname = getNicknameFromActor(searchHandle) @@ -287,7 +287,7 @@ def htmlModerationInfo(cssCache: {}, translate: {}, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') infoForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) infoForm += \ diff --git a/webapp_person_options.py b/webapp_person_options.py index f78175158..84646af1f 100644 --- a/webapp_person_options.py +++ b/webapp_person_options.py @@ -13,7 +13,7 @@ from petnames import getPetName from person import isPersonSnoozed from posts import isModerator from utils import get_full_domain -from utils import getConfigParam +from utils import get_config_param from utils import is_dormant from utils import removeHtml from utils import getDomainFromActor @@ -129,7 +129,7 @@ def htmlPersonOptions(defaultTimeline: str, translate['Donate'] + '\n' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) optionsStr += htmlKeyboardNavigation(text_mode_banner, {}, {}) optionsStr += '

\n' @@ -289,7 +289,7 @@ def htmlPersonOptions(defaultTimeline: str, # checkbox for permission to post to newswire newswirePostsPermitted = False if optionsDomainFull == domain_full: - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if (nickname == adminNickname or (isModerator(base_dir, nickname) and not isModerator(base_dir, optionsNickname))): @@ -330,7 +330,7 @@ def htmlPersonOptions(defaultTimeline: str, # checkbox for permission to post to featured articles if news_instance and optionsDomainFull == domain_full: - adminNickname = getConfigParam(base_dir, 'admin') + adminNickname = get_config_param(base_dir, 'admin') if (nickname == adminNickname or (isModerator(base_dir, nickname) and not isModerator(base_dir, optionsNickname))): diff --git a/webapp_post.py b/webapp_post.py index bb4adb470..1a5c58dc3 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -34,7 +34,7 @@ from utils import isPGPEncrypted from utils import isDM from utils import rejectPostId from utils import isRecentPost -from utils import getConfigParam +from utils import get_config_param from utils import get_full_domain from utils import is_editor from utils import locatePost @@ -2146,7 +2146,7 @@ def htmlIndividualPost(cssCache: {}, cssFilename = base_dir + '/epicyon.css' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') metadataStr = _htmlPostMetadataOpenGraph(domain, originalPostJson) headerStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, metadataStr) @@ -2197,7 +2197,7 @@ def htmlPostReplies(cssCache: {}, if os.path.isfile(base_dir + '/epicyon.css'): cssFilename = base_dir + '/epicyon.css' - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceTitle = get_config_param(base_dir, 'instanceTitle') metadata = '' headerStr = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, metadata) @@ -2275,7 +2275,7 @@ def htmlEmojiReactionPicker(cssCache: {}, bannerFile, _ = \ getBannerFile(base_dir, nickname, domain, theme_name) - instanceTitle = getConfigParam(base_dir, 'instanceTitle') + instanceTitle = get_config_param(base_dir, 'instanceTitle') metadata = '' headerStr = \ htmlHeaderWithExternalStyle(cssFilename, instanceTitle, metadata) diff --git a/webapp_profile.py b/webapp_profile.py index 4f312784a..05c1308d2 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -23,7 +23,7 @@ from utils import getDomainFromActor from utils import isSystemAccount from utils import removeHtml from utils import loadJson -from utils import getConfigParam +from utils import get_config_param from utils import getImageFormats from utils import acct_dir from utils import getSupportedLanguages @@ -356,7 +356,7 @@ def htmlProfileAfterSearch(cssCache: {}, break instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') return htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) + \ profileStr + htmlFooter() @@ -1016,7 +1016,7 @@ def htmlProfile(signing_priv_key_pem: str, profileStr += '' instanceTitle = \ - getConfigParam(base_dir, 'instanceTitle') + get_config_param(base_dir, 'instanceTitle') profileStr = \ htmlHeaderWithPersonMarkup(cssFilename, instanceTitle, profile_json, city, @@ -1242,7 +1242,7 @@ def _htmlThemesDropdown(base_dir: str, translate: {}) -> str: themesDropdown += \ editCheckBox(translate['Remove the custom font'], 'removeCustomFont', False) - theme_name = getConfigParam(base_dir, 'theme') + theme_name = get_config_param(base_dir, 'theme') themesDropdown = \ themesDropdown.replace('