mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
74ee5eeb7e
commit
b8d460b496
|
@ -1138,15 +1138,15 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
|
|
||||||
|
|
||||||
def extractTextFieldsInPOST(postBytes, boundary: str, debug: bool,
|
def extractTextFieldsInPOST(postBytes, boundary: str, debug: bool,
|
||||||
unitTestData: str = None) -> {}:
|
unit_testData: str = None) -> {}:
|
||||||
"""Returns a dictionary containing the text fields of a http form POST
|
"""Returns a dictionary containing the text fields of a http form POST
|
||||||
The boundary argument comes from the http header
|
The boundary argument comes from the http header
|
||||||
"""
|
"""
|
||||||
if not unitTestData:
|
if not unit_testData:
|
||||||
msgBytes = email.parser.BytesParser().parsebytes(postBytes)
|
msgBytes = email.parser.BytesParser().parsebytes(postBytes)
|
||||||
messageFields = msgBytes.get_payload(decode=True).decode('utf-8')
|
messageFields = msgBytes.get_payload(decode=True).decode('utf-8')
|
||||||
else:
|
else:
|
||||||
messageFields = unitTestData
|
messageFields = unit_testData
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST arriving ' + messageFields)
|
print('DEBUG: POST arriving ' + messageFields)
|
||||||
|
|
20
daemon.py
20
daemon.py
|
@ -18283,7 +18283,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'_POST', 'keyId check',
|
'_POST', 'keyId check',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
if not self.server.unitTest:
|
if not self.server.unit_test:
|
||||||
if not inboxPermittedMessage(self.server.domain,
|
if not inboxPermittedMessage(self.server.domain,
|
||||||
messageJson,
|
messageJson,
|
||||||
self.server.federationList):
|
self.server.federationList):
|
||||||
|
@ -18480,7 +18480,7 @@ def runDaemon(content_license_url: str,
|
||||||
domain_max_posts_per_day: int = 8640,
|
domain_max_posts_per_day: int = 8640,
|
||||||
account_max_posts_per_day: int = 864,
|
account_max_posts_per_day: int = 864,
|
||||||
allow_deletion: bool = False,
|
allow_deletion: bool = False,
|
||||||
debug: bool = False, unitTest: bool = False,
|
debug: bool = False, unit_test: bool = False,
|
||||||
instanceOnlySkillsSearch: bool = False,
|
instanceOnlySkillsSearch: bool = False,
|
||||||
sendThreads: [] = [],
|
sendThreads: [] = [],
|
||||||
manualFollowerApproval: bool = True) -> None:
|
manualFollowerApproval: bool = True) -> None:
|
||||||
|
@ -18491,7 +18491,7 @@ def runDaemon(content_license_url: str,
|
||||||
print('Invalid domain: ' + domain)
|
print('Invalid domain: ' + domain)
|
||||||
return
|
return
|
||||||
|
|
||||||
if unitTest:
|
if unit_test:
|
||||||
serverAddress = (domain, proxy_port)
|
serverAddress = (domain, proxy_port)
|
||||||
pubHandler = partial(PubServerUnitTest)
|
pubHandler = partial(PubServerUnitTest)
|
||||||
else:
|
else:
|
||||||
|
@ -18592,9 +18592,9 @@ def runDaemon(content_license_url: str,
|
||||||
# list of blocked user agent types within the User-Agent header
|
# list of blocked user agent types within the User-Agent header
|
||||||
httpd.user_agents_blocked = user_agents_blocked
|
httpd.user_agents_blocked = user_agents_blocked
|
||||||
|
|
||||||
httpd.unitTest = unitTest
|
httpd.unit_test = unit_test
|
||||||
httpd.allow_local_network_access = allow_local_network_access
|
httpd.allow_local_network_access = allow_local_network_access
|
||||||
if unitTest:
|
if unit_test:
|
||||||
# unit tests are run on the local network with LAN addresses
|
# unit tests are run on the local network with LAN addresses
|
||||||
httpd.allow_local_network_access = True
|
httpd.allow_local_network_access = True
|
||||||
httpd.yt_replace_domain = yt_replace_domain
|
httpd.yt_replace_domain = yt_replace_domain
|
||||||
|
@ -18624,7 +18624,7 @@ def runDaemon(content_license_url: str,
|
||||||
# load translations dictionary
|
# load translations dictionary
|
||||||
httpd.translate = {}
|
httpd.translate = {}
|
||||||
httpd.systemLanguage = 'en'
|
httpd.systemLanguage = 'en'
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
httpd.translate, httpd.systemLanguage = \
|
httpd.translate, httpd.systemLanguage = \
|
||||||
loadTranslationsFromFile(base_dir, language)
|
loadTranslationsFromFile(base_dir, language)
|
||||||
if not httpd.systemLanguage:
|
if not httpd.systemLanguage:
|
||||||
|
@ -18875,7 +18875,7 @@ def runDaemon(content_license_url: str,
|
||||||
threadWithTrace(target=runPostsQueue,
|
threadWithTrace(target=runPostsQueue,
|
||||||
args=(base_dir, httpd.sendThreads, debug,
|
args=(base_dir, httpd.sendThreads, debug,
|
||||||
httpd.send_threads_timeout_mins), daemon=True)
|
httpd.send_threads_timeout_mins), daemon=True)
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
httpd.thrPostsWatchdog = \
|
httpd.thrPostsWatchdog = \
|
||||||
threadWithTrace(target=runPostsWatchdog,
|
threadWithTrace(target=runPostsWatchdog,
|
||||||
args=(project_version, httpd), daemon=True)
|
args=(project_version, httpd), daemon=True)
|
||||||
|
@ -18887,7 +18887,7 @@ def runDaemon(content_license_url: str,
|
||||||
httpd.thrSharesExpire = \
|
httpd.thrSharesExpire = \
|
||||||
threadWithTrace(target=runSharesExpire,
|
threadWithTrace(target=runSharesExpire,
|
||||||
args=(project_version, base_dir), daemon=True)
|
args=(project_version, base_dir), daemon=True)
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
httpd.thrSharesExpireWatchdog = \
|
httpd.thrSharesExpireWatchdog = \
|
||||||
threadWithTrace(target=runSharesExpireWatchdog,
|
threadWithTrace(target=runSharesExpireWatchdog,
|
||||||
args=(project_version, httpd), daemon=True)
|
args=(project_version, httpd), daemon=True)
|
||||||
|
@ -18932,7 +18932,7 @@ def runDaemon(content_license_url: str,
|
||||||
account_max_posts_per_day,
|
account_max_posts_per_day,
|
||||||
allow_deletion, debug,
|
allow_deletion, debug,
|
||||||
max_mentions, max_emoji,
|
max_mentions, max_emoji,
|
||||||
httpd.translate, unitTest,
|
httpd.translate, unit_test,
|
||||||
httpd.yt_replace_domain,
|
httpd.yt_replace_domain,
|
||||||
httpd.twitter_replacement_domain,
|
httpd.twitter_replacement_domain,
|
||||||
httpd.show_published_date_only,
|
httpd.show_published_date_only,
|
||||||
|
@ -18980,7 +18980,7 @@ def runDaemon(content_license_url: str,
|
||||||
# this is the instance actor private key
|
# this is the instance actor private key
|
||||||
httpd.signingPrivateKeyPem = getInstanceActorKey(base_dir, domain)
|
httpd.signingPrivateKeyPem = getInstanceActorKey(base_dir, domain)
|
||||||
|
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
print('Creating inbox queue watchdog')
|
print('Creating inbox queue watchdog')
|
||||||
httpd.thrWatchdog = \
|
httpd.thrWatchdog = \
|
||||||
threadWithTrace(target=runInboxQueueWatchdog,
|
threadWithTrace(target=runInboxQueueWatchdog,
|
||||||
|
|
16
inbox.py
16
inbox.py
|
@ -3187,7 +3187,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
|
||||||
queueFilename: str, destinationFilename: str,
|
queueFilename: str, destinationFilename: str,
|
||||||
max_replies: int, allow_deletion: bool,
|
max_replies: int, allow_deletion: bool,
|
||||||
max_mentions: int, max_emoji: int, translate: {},
|
max_mentions: int, max_emoji: int, translate: {},
|
||||||
unitTest: bool,
|
unit_test: bool,
|
||||||
yt_replace_domain: str,
|
yt_replace_domain: str,
|
||||||
twitter_replacement_domain: str,
|
twitter_replacement_domain: str,
|
||||||
show_published_date_only: bool,
|
show_published_date_only: bool,
|
||||||
|
@ -3422,7 +3422,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
|
||||||
# is the sending actor valid?
|
# is the sending actor valid?
|
||||||
if not validSendingActor(session, base_dir, nickname, domain,
|
if not validSendingActor(session, base_dir, nickname, domain,
|
||||||
personCache, postJsonObject,
|
personCache, postJsonObject,
|
||||||
signingPrivateKeyPem, debug, unitTest):
|
signingPrivateKeyPem, debug, unit_test):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if postJsonObject.get('object'):
|
if postJsonObject.get('object'):
|
||||||
|
@ -3546,7 +3546,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
|
||||||
nickname, domain, domainFull,
|
nickname, domain, domainFull,
|
||||||
postJsonObject, personCache,
|
postJsonObject, personCache,
|
||||||
translate, None, themeName)
|
translate, None, themeName)
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
if debug:
|
if debug:
|
||||||
print('Saving inbox post as html to cache')
|
print('Saving inbox post as html to cache')
|
||||||
|
|
||||||
|
@ -3850,7 +3850,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
|
||||||
messageJson: {}, federationList: [],
|
messageJson: {}, federationList: [],
|
||||||
debug: bool, project_version: str,
|
debug: bool, project_version: str,
|
||||||
max_followers: int, onion_domain: str,
|
max_followers: int, onion_domain: str,
|
||||||
signingPrivateKeyPem: str, unitTest: bool) -> bool:
|
signingPrivateKeyPem: str, unit_test: bool) -> bool:
|
||||||
"""Receives a follow request within the POST section of HTTPServer
|
"""Receives a follow request within the POST section of HTTPServer
|
||||||
"""
|
"""
|
||||||
if not messageJson['type'].startswith('Follow'):
|
if not messageJson['type'].startswith('Follow'):
|
||||||
|
@ -3933,7 +3933,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
|
||||||
if not validSendingActor(session, base_dir,
|
if not validSendingActor(session, base_dir,
|
||||||
nicknameToFollow, domainToFollow,
|
nicknameToFollow, domainToFollow,
|
||||||
personCache, messageJson,
|
personCache, messageJson,
|
||||||
signingPrivateKeyPem, debug, unitTest):
|
signingPrivateKeyPem, debug, unit_test):
|
||||||
print('REJECT spam follow request ' + approveHandle)
|
print('REJECT spam follow request ' + approveHandle)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -4071,7 +4071,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
|
||||||
domain_max_posts_per_day: int,
|
domain_max_posts_per_day: int,
|
||||||
account_max_posts_per_day: int,
|
account_max_posts_per_day: int,
|
||||||
allow_deletion: bool, debug: bool, max_mentions: int,
|
allow_deletion: bool, debug: bool, max_mentions: int,
|
||||||
max_emoji: int, translate: {}, unitTest: bool,
|
max_emoji: int, translate: {}, unit_test: bool,
|
||||||
yt_replace_domain: str,
|
yt_replace_domain: str,
|
||||||
twitter_replacement_domain: str,
|
twitter_replacement_domain: str,
|
||||||
show_published_date_only: bool,
|
show_published_date_only: bool,
|
||||||
|
@ -4373,7 +4373,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
|
||||||
federationList,
|
federationList,
|
||||||
debug, project_version,
|
debug, project_version,
|
||||||
max_followers, onion_domain,
|
max_followers, onion_domain,
|
||||||
signingPrivateKeyPem, unitTest):
|
signingPrivateKeyPem, unit_test):
|
||||||
if os.path.isfile(queueFilename):
|
if os.path.isfile(queueFilename):
|
||||||
try:
|
try:
|
||||||
os.remove(queueFilename)
|
os.remove(queueFilename)
|
||||||
|
@ -4502,7 +4502,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
|
||||||
queueFilename, destination,
|
queueFilename, destination,
|
||||||
max_replies, allow_deletion,
|
max_replies, allow_deletion,
|
||||||
max_mentions, max_emoji,
|
max_mentions, max_emoji,
|
||||||
translate, unitTest,
|
translate, unit_test,
|
||||||
yt_replace_domain,
|
yt_replace_domain,
|
||||||
twitter_replacement_domain,
|
twitter_replacement_domain,
|
||||||
show_published_date_only,
|
show_published_date_only,
|
||||||
|
|
|
@ -1657,7 +1657,7 @@ def validSendingActor(session, base_dir: str,
|
||||||
personCache: {},
|
personCache: {},
|
||||||
postJsonObject: {},
|
postJsonObject: {},
|
||||||
signingPrivateKeyPem: str,
|
signingPrivateKeyPem: str,
|
||||||
debug: bool, unitTest: bool) -> bool:
|
debug: bool, unit_test: bool) -> bool:
|
||||||
"""When a post arrives in the inbox this is used to check that
|
"""When a post arrives in the inbox this is used to check that
|
||||||
the sending actor is valid
|
the sending actor is valid
|
||||||
"""
|
"""
|
||||||
|
@ -1689,7 +1689,7 @@ def validSendingActor(session, base_dir: str,
|
||||||
print('REJECT: no preferredUsername within actor ' + str(actorJson))
|
print('REJECT: no preferredUsername within actor ' + str(actorJson))
|
||||||
return False
|
return False
|
||||||
# does the actor have a bio ?
|
# does the actor have a bio ?
|
||||||
if not unitTest:
|
if not unit_test:
|
||||||
bioStr = ''
|
bioStr = ''
|
||||||
if actorJson.get('summary'):
|
if actorJson.get('summary'):
|
||||||
bioStr = removeHtml(actorJson['summary']).strip()
|
bioStr = removeHtml(actorJson['summary']).strip()
|
||||||
|
|
Loading…
Reference in New Issue