Snake case

main
Bob Mottram 2021-12-25 20:43:43 +00:00
parent 0203107e1a
commit 2e157b5441
12 changed files with 349 additions and 347 deletions

View File

@ -139,7 +139,7 @@ def getWebfingerFromCache(handle: str, cachedWebfingers: {}) -> {}:
def getPersonPubKey(base_dir: str, session, personUrl: str, def getPersonPubKey(base_dir: str, session, personUrl: str,
personCache: {}, debug: bool, personCache: {}, debug: bool,
project_version: str, http_prefix: str, project_version: str, http_prefix: str,
domain: str, onionDomain: str, domain: str, onion_domain: str,
signingPrivateKeyPem: str) -> str: signingPrivateKeyPem: str) -> str:
if not personUrl: if not personUrl:
return None return None
@ -158,9 +158,9 @@ def getPersonPubKey(base_dir: str, session, personUrl: str,
if debug: if debug:
print('DEBUG: Obtaining public key for ' + personUrl) print('DEBUG: Obtaining public key for ' + personUrl)
personDomain = domain personDomain = domain
if onionDomain: if onion_domain:
if '.onion/' in personUrl: if '.onion/' in personUrl:
personDomain = onionDomain personDomain = onion_domain
profileStr = 'https://www.w3.org/ns/activitystreams' profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = { asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"' 'Accept': 'application/activity+json; profile="' + profileStr + '"'

530
daemon.py

File diff suppressed because it is too large Load Diff

View File

@ -1055,8 +1055,8 @@ if args.onion:
sys.exit() sys.exit()
if '://' in args.onion: if '://' in args.onion:
args.onion = args.onion.split('://')[1] args.onion = args.onion.split('://')[1]
onionDomain = args.onion onion_domain = args.onion
setConfigParam(base_dir, 'onion', onionDomain) setConfigParam(base_dir, 'onion', onion_domain)
i2pDomain = None i2pDomain = None
if args.i2pDomain: if args.i2pDomain:
@ -1116,9 +1116,9 @@ else:
# get onion domain name from configuration # get onion domain name from configuration
configOnionDomain = getConfigParam(base_dir, 'onion') configOnionDomain = getConfigParam(base_dir, 'onion')
if configOnionDomain: if configOnionDomain:
onionDomain = configOnionDomain onion_domain = configOnionDomain
else: else:
onionDomain = None onion_domain = None
# get i2p domain name from configuration # get i2p domain name from configuration
configi2pDomain = getConfigParam(base_dir, 'i2pDomain') configi2pDomain = getConfigParam(base_dir, 'i2pDomain')
@ -3247,7 +3247,7 @@ if __name__ == "__main__":
not args.nosharedinbox, not args.nosharedinbox,
registration, args.language, __version__, registration, args.language, __version__,
instance_id, args.client, base_dir, instance_id, args.client, base_dir,
domain, onionDomain, i2pDomain, domain, onion_domain, i2pDomain,
args.yt_replace_domain, args.yt_replace_domain,
args.twitterReplacementDomain, args.twitterReplacementDomain,
port, proxyPort, http_prefix, port, proxyPort, http_prefix,

View File

@ -992,7 +992,7 @@ def _receiveUpdate(recentPostsCache: {}, session, base_dir: str,
def _receiveLike(recentPostsCache: {}, def _receiveLike(recentPostsCache: {},
session, handle: str, isGroup: bool, base_dir: str, session, handle: str, isGroup: bool, base_dir: str,
http_prefix: str, domain: str, port: int, http_prefix: str, domain: str, port: int,
onionDomain: str, onion_domain: str,
sendThreads: [], postLog: [], cachedWebfingers: {}, sendThreads: [], postLog: [], cachedWebfingers: {},
personCache: {}, messageJson: {}, federationList: [], personCache: {}, messageJson: {}, federationList: [],
debug: bool, debug: bool,
@ -1050,7 +1050,7 @@ def _receiveLike(recentPostsCache: {},
handleName, handleDom, handleName, handleDom,
postLikedId, postLikedId,
likeActor): likeActor):
_likeNotify(base_dir, domain, onionDomain, handle, _likeNotify(base_dir, domain, onion_domain, handle,
likeActor, postLikedId) likeActor, postLikedId)
updateLikesCollection(recentPostsCache, base_dir, postFilename, updateLikesCollection(recentPostsCache, base_dir, postFilename,
postLikedId, likeActor, postLikedId, likeActor,
@ -1226,7 +1226,7 @@ def _receiveUndoLike(recentPostsCache: {},
def _receiveReaction(recentPostsCache: {}, def _receiveReaction(recentPostsCache: {},
session, handle: str, isGroup: bool, base_dir: str, session, handle: str, isGroup: bool, base_dir: str,
http_prefix: str, domain: str, port: int, http_prefix: str, domain: str, port: int,
onionDomain: str, onion_domain: str,
sendThreads: [], postLog: [], cachedWebfingers: {}, sendThreads: [], postLog: [], cachedWebfingers: {},
personCache: {}, messageJson: {}, federationList: [], personCache: {}, messageJson: {}, federationList: [],
debug: bool, debug: bool,
@ -1308,7 +1308,7 @@ def _receiveReaction(recentPostsCache: {},
postReactionId, postReactionId,
reactionActor, reactionActor,
emojiContent): emojiContent):
_reactionNotify(base_dir, domain, onionDomain, handle, _reactionNotify(base_dir, domain, onion_domain, handle,
reactionActor, postReactionId, emojiContent) reactionActor, postReactionId, emojiContent)
updateReactionCollection(recentPostsCache, base_dir, postFilename, updateReactionCollection(recentPostsCache, base_dir, postFilename,
postReactionId, reactionActor, postReactionId, reactionActor,
@ -1796,7 +1796,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
def _receiveAnnounce(recentPostsCache: {}, def _receiveAnnounce(recentPostsCache: {},
session, handle: str, isGroup: bool, base_dir: str, session, handle: str, isGroup: bool, base_dir: str,
http_prefix: str, http_prefix: str,
domain: str, onionDomain: str, port: int, domain: str, onion_domain: str, port: int,
sendThreads: [], postLog: [], cachedWebfingers: {}, sendThreads: [], postLog: [], cachedWebfingers: {},
personCache: {}, messageJson: {}, federationList: [], personCache: {}, messageJson: {}, federationList: [],
debug: bool, translate: {}, debug: bool, translate: {},
@ -1946,8 +1946,8 @@ def _receiveAnnounce(recentPostsCache: {},
if not postJsonObject: if not postJsonObject:
print('WARN: unable to download announce: ' + str(messageJson)) print('WARN: unable to download announce: ' + str(messageJson))
notInOnion = True notInOnion = True
if onionDomain: if onion_domain:
if onionDomain in messageJson['object']: if onion_domain in messageJson['object']:
notInOnion = False notInOnion = False
if domain not in messageJson['object'] and notInOnion: if domain not in messageJson['object'] and notInOnion:
if os.path.isfile(postFilename): if os.path.isfile(postFilename):
@ -2004,7 +2004,7 @@ def _receiveAnnounce(recentPostsCache: {},
getPersonPubKey(base_dir, session, lookupActor, getPersonPubKey(base_dir, session, lookupActor,
personCache, debug, personCache, debug,
__version__, http_prefix, __version__, http_prefix,
domain, onionDomain, domain, onion_domain,
signingPrivateKeyPem) signingPrivateKeyPem)
if pubKey: if pubKey:
if debug: if debug:
@ -2290,7 +2290,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
def _obtainAvatarForReplyPost(session, base_dir: str, http_prefix: str, def _obtainAvatarForReplyPost(session, base_dir: str, http_prefix: str,
domain: str, onionDomain: str, personCache: {}, domain: str, onion_domain: str, personCache: {},
postJsonObject: {}, debug: bool, postJsonObject: {}, debug: bool,
signingPrivateKeyPem: str) -> None: signingPrivateKeyPem: str) -> None:
"""Tries to obtain the actor for the person being replied to """Tries to obtain the actor for the person being replied to
@ -2323,7 +2323,7 @@ def _obtainAvatarForReplyPost(session, base_dir: str, http_prefix: str,
getPersonPubKey(base_dir, session, lookupActor, getPersonPubKey(base_dir, session, lookupActor,
personCache, debug, personCache, debug,
__version__, http_prefix, __version__, http_prefix,
domain, onionDomain, signingPrivateKeyPem) domain, onion_domain, signingPrivateKeyPem)
if pubKey: if pubKey:
if debug: if debug:
print('DEBUG: public key obtained for reply: ' + lookupActor) print('DEBUG: public key obtained for reply: ' + lookupActor)
@ -2413,7 +2413,7 @@ def _alreadyReacted(base_dir: str, nickname: str, domain: str,
return False return False
def _likeNotify(base_dir: str, domain: str, onionDomain: str, def _likeNotify(base_dir: str, domain: str, onion_domain: str,
handle: str, actor: str, url: str) -> None: handle: str, actor: str, url: str) -> None:
"""Creates a notification that a like has arrived """Creates a notification that a like has arrived
""" """
@ -2424,9 +2424,9 @@ def _likeNotify(base_dir: str, domain: str, onionDomain: str,
# check that the liked post was by this handle # check that the liked post was by this handle
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if '/' + domain + '/users/' + nickname not in url: if '/' + domain + '/users/' + nickname not in url:
if not onionDomain: if not onion_domain:
return return
if '/' + onionDomain + '/users/' + nickname not in url: if '/' + onion_domain + '/users/' + nickname not in url:
return return
accountDir = base_dir + '/accounts/' + handle accountDir = base_dir + '/accounts/' + handle
@ -2474,7 +2474,7 @@ def _likeNotify(base_dir: str, domain: str, onionDomain: str,
likeFile) likeFile)
def _reactionNotify(base_dir: str, domain: str, onionDomain: str, def _reactionNotify(base_dir: str, domain: str, onion_domain: str,
handle: str, actor: str, handle: str, actor: str,
url: str, emojiContent: str) -> None: url: str, emojiContent: str) -> None:
"""Creates a notification that an emoji reaction has arrived """Creates a notification that an emoji reaction has arrived
@ -2486,9 +2486,9 @@ def _reactionNotify(base_dir: str, domain: str, onionDomain: str,
# check that the reaction post was by this handle # check that the reaction post was by this handle
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if '/' + domain + '/users/' + nickname not in url: if '/' + domain + '/users/' + nickname not in url:
if not onionDomain: if not onion_domain:
return return
if '/' + onionDomain + '/users/' + nickname not in url: if '/' + onion_domain + '/users/' + nickname not in url:
return return
accountDir = base_dir + '/accounts/' + handle accountDir = base_dir + '/accounts/' + handle
@ -2611,7 +2611,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
sendThreads: [], postLog: [], cachedWebfingers: {}, sendThreads: [], postLog: [], cachedWebfingers: {},
personCache: {}, debug: bool, personCache: {}, debug: bool,
systemLanguage: str, systemLanguage: str,
onionDomain: str, i2pDomain: str, onion_domain: str, i2pDomain: str,
signingPrivateKeyPem: str) -> None: signingPrivateKeyPem: str) -> None:
"""When a post arrives for a group send it out to the group members """When a post arrives for a group send it out to the group members
""" """
@ -2666,7 +2666,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
debug, __version__, signingPrivateKeyPem) debug, __version__, signingPrivateKeyPem)
sendToFollowersThread(session, base_dir, nickname, domain, sendToFollowersThread(session, base_dir, nickname, domain,
onionDomain, i2pDomain, port, onion_domain, i2pDomain, port,
http_prefix, federationList, http_prefix, federationList,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -2974,7 +2974,7 @@ def _isValidDM(base_dir: str, nickname: str, domain: str, port: int,
def _receiveQuestionVote(base_dir: str, nickname: str, domain: str, def _receiveQuestionVote(base_dir: str, nickname: str, domain: str,
http_prefix: str, handle: str, debug: bool, http_prefix: str, handle: str, debug: bool,
postJsonObject: {}, recentPostsCache: {}, postJsonObject: {}, recentPostsCache: {},
session, onionDomain: str, i2pDomain: str, port: int, session, onion_domain: str, i2pDomain: str, port: int,
federationList: [], sendThreads: [], postLog: [], federationList: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
signingPrivateKeyPem: str, signingPrivateKeyPem: str,
@ -3050,7 +3050,7 @@ def _receiveQuestionVote(base_dir: str, nickname: str, domain: str,
shared_items_federated_domains = [] shared_items_federated_domains = []
sharedItemFederationTokens = {} sharedItemFederationTokens = {}
sendToFollowersThread(session, base_dir, nickname, domain, sendToFollowersThread(session, base_dir, nickname, domain,
onionDomain, i2pDomain, port, onion_domain, i2pDomain, port,
http_prefix, federationList, http_prefix, federationList,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -3180,7 +3180,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
base_dir: str, http_prefix: str, sendThreads: [], base_dir: str, http_prefix: str, sendThreads: [],
postLog: [], cachedWebfingers: {}, personCache: {}, postLog: [], cachedWebfingers: {}, personCache: {},
queue: [], domain: str, queue: [], domain: str,
onionDomain: str, i2pDomain: str, onion_domain: str, i2pDomain: str,
port: int, proxyType: str, port: int, proxyType: str,
federationList: [], debug: bool, federationList: [], debug: bool,
queueFilename: str, destinationFilename: str, queueFilename: str, destinationFilename: str,
@ -3214,7 +3214,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
session, handle, isGroup, session, handle, isGroup,
base_dir, http_prefix, base_dir, http_prefix,
domain, port, domain, port,
onionDomain, onion_domain,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, cachedWebfingers,
personCache, personCache,
@ -3259,7 +3259,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
session, handle, isGroup, session, handle, isGroup,
base_dir, http_prefix, base_dir, http_prefix,
domain, port, domain, port,
onionDomain, onion_domain,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, cachedWebfingers,
personCache, personCache,
@ -3350,7 +3350,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
if _receiveAnnounce(recentPostsCache, if _receiveAnnounce(recentPostsCache,
session, handle, isGroup, session, handle, isGroup,
base_dir, http_prefix, base_dir, http_prefix,
domain, onionDomain, port, domain, onion_domain, port,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, cachedWebfingers,
personCache, personCache,
@ -3450,7 +3450,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
_receiveQuestionVote(base_dir, nickname, domain, _receiveQuestionVote(base_dir, nickname, domain,
http_prefix, handle, debug, http_prefix, handle, debug,
postJsonObject, recentPostsCache, postJsonObject, recentPostsCache,
session, onionDomain, i2pDomain, port, session, onion_domain, i2pDomain, port,
federationList, sendThreads, postLog, federationList, sendThreads, postLog,
cachedWebfingers, personCache, cachedWebfingers, personCache,
signingPrivateKeyPem, signingPrivateKeyPem,
@ -3511,7 +3511,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
# get the avatar for a reply/announce # get the avatar for a reply/announce
_obtainAvatarForReplyPost(session, base_dir, _obtainAvatarForReplyPost(session, base_dir,
http_prefix, domain, onionDomain, http_prefix, domain, onion_domain,
personCache, postJsonObject, debug, personCache, postJsonObject, debug,
signingPrivateKeyPem) signingPrivateKeyPem)
@ -3610,7 +3610,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
http_prefix, federationList, sendThreads, http_prefix, federationList, sendThreads,
postLog, cachedWebfingers, personCache, postLog, cachedWebfingers, personCache,
debug, systemLanguage, debug, systemLanguage,
onionDomain, i2pDomain, onion_domain, i2pDomain,
signingPrivateKeyPem) signingPrivateKeyPem)
# if the post wasn't saved # if the post wasn't saved
@ -3848,7 +3848,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
messageJson: {}, federationList: [], messageJson: {}, federationList: [],
debug: bool, project_version: str, debug: bool, project_version: str,
max_followers: int, onionDomain: str, max_followers: int, onion_domain: str,
signingPrivateKeyPem: str, unitTest: bool) -> bool: signingPrivateKeyPem: str, unitTest: bool) -> bool:
"""Receives a follow request within the POST section of HTTPServer """Receives a follow request within the POST section of HTTPServer
""" """
@ -3968,7 +3968,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print('Obtaining the following actor: ' + messageJson['actor']) print('Obtaining the following actor: ' + messageJson['actor'])
if not getPersonPubKey(base_dir, session, messageJson['actor'], if not getPersonPubKey(base_dir, session, messageJson['actor'],
personCache, debug, project_version, personCache, debug, project_version,
http_prefix, domainToFollow, onionDomain, http_prefix, domainToFollow, onion_domain,
signingPrivateKeyPem): signingPrivateKeyPem):
if debug: if debug:
print('Unable to obtain following actor: ' + print('Unable to obtain following actor: ' +
@ -4005,7 +4005,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
print('Obtaining the following actor: ' + messageJson['actor']) print('Obtaining the following actor: ' + messageJson['actor'])
if not getPersonPubKey(base_dir, session, messageJson['actor'], if not getPersonPubKey(base_dir, session, messageJson['actor'],
personCache, debug, project_version, personCache, debug, project_version,
http_prefix, domainToFollow, onionDomain, http_prefix, domainToFollow, onion_domain,
signingPrivateKeyPem): signingPrivateKeyPem):
if debug: if debug:
print('Unable to obtain following actor: ' + print('Unable to obtain following actor: ' +
@ -4064,7 +4064,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
sendThreads: [], postLog: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, queue: [], cachedWebfingers: {}, personCache: {}, queue: [],
domain: str, domain: str,
onionDomain: str, i2pDomain: str, onion_domain: str, i2pDomain: str,
port: int, proxyType: str, port: int, proxyType: str,
federationList: [], maxReplies: int, federationList: [], maxReplies: int,
domainMaxPostsPerDay: int, domainMaxPostsPerDay: int,
@ -4233,7 +4233,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
getPersonPubKey(base_dir, session, keyId, getPersonPubKey(base_dir, session, keyId,
personCache, debug, personCache, debug,
project_version, http_prefix, project_version, http_prefix,
domain, onionDomain, signingPrivateKeyPem) domain, onion_domain, signingPrivateKeyPem)
if pubKey: if pubKey:
if debug: if debug:
print('DEBUG: public key: ' + str(pubKey)) print('DEBUG: public key: ' + str(pubKey))
@ -4371,7 +4371,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
queueJson['post'], queueJson['post'],
federationList, federationList,
debug, project_version, debug, project_version,
max_followers, onionDomain, max_followers, onion_domain,
signingPrivateKeyPem, unitTest): signingPrivateKeyPem, unitTest):
if os.path.isfile(queueFilename): if os.path.isfile(queueFilename):
try: try:
@ -4494,7 +4494,7 @@ def runInboxQueue(recentPostsCache: {}, max_recent_posts: int,
cachedWebfingers, cachedWebfingers,
personCache, queue, personCache, queue,
domain, domain,
onionDomain, i2pDomain, onion_domain, i2pDomain,
port, proxyType, port, proxyType,
federationList, federationList,
debug, debug,

View File

@ -87,7 +87,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
http_prefix: str, http_prefix: str,
base_dir: str, nickname: str, domain: str, base_dir: str, nickname: str, domain: str,
domainFull: str, domainFull: str,
onionDomain: str, i2pDomain: str, onion_domain: str, i2pDomain: str,
translate: {}, translate: {},
registration: bool, registration: bool,
systemLanguage: str, systemLanguage: str,
@ -208,8 +208,8 @@ def mastoApiV1Response(path: str, callingDomain: str,
'instanceDescription') 'instanceDescription')
instanceTitle = getConfigParam(base_dir, 'instanceTitle') instanceTitle = getConfigParam(base_dir, 'instanceTitle')
if callingDomain.endswith('.onion') and onionDomain: if callingDomain.endswith('.onion') and onion_domain:
domainFull = onionDomain domainFull = onion_domain
http_prefix = 'http' http_prefix = 'http'
elif (callingDomain.endswith('.i2p') and i2pDomain): elif (callingDomain.endswith('.i2p') and i2pDomain):
domainFull = i2pDomain domainFull = i2pDomain

View File

@ -181,7 +181,7 @@ def postMessageToOutbox(session, translate: {},
messageJson: {}, postToNickname: str, messageJson: {}, postToNickname: str,
server, base_dir: str, http_prefix: str, server, base_dir: str, http_prefix: str,
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, port: int, onion_domain: str, i2pDomain: str, port: int,
recentPostsCache: {}, followersThreads: [], recentPostsCache: {}, followersThreads: [],
federationList: [], sendThreads: [], federationList: [], sendThreads: [],
postLog: [], cachedWebfingers: {}, postLog: [], cachedWebfingers: {},
@ -512,7 +512,7 @@ def postMessageToOutbox(session, translate: {},
sendToFollowersThread(server.session, sendToFollowersThread(server.session,
base_dir, base_dir,
postToNickname, postToNickname,
domain, onionDomain, i2pDomain, domain, onion_domain, i2pDomain,
port, http_prefix, port, http_prefix,
federationList, federationList,
sendThreads, sendThreads,
@ -653,7 +653,7 @@ def postMessageToOutbox(session, translate: {},
namedAddressesThread = \ namedAddressesThread = \
sendToNamedAddressesThread(server.session, base_dir, sendToNamedAddressesThread(server.session, base_dir,
postToNickname, postToNickname,
domain, onionDomain, i2pDomain, port, domain, onion_domain, i2pDomain, port,
http_prefix, http_prefix,
federationList, federationList,
sendThreads, sendThreads,

View File

@ -2858,7 +2858,7 @@ def _isProfileUpdate(postJsonObject: {}) -> bool:
def _sendToNamedAddresses(session, base_dir: str, def _sendToNamedAddresses(session, base_dir: str,
nickname: str, domain: str, nickname: str, domain: str,
onionDomain: str, i2pDomain: str, port: int, onion_domain: str, i2pDomain: str, port: int,
http_prefix: str, federationList: [], http_prefix: str, federationList: [],
sendThreads: [], postLog: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
@ -2974,10 +2974,10 @@ def _sendToNamedAddresses(session, base_dir: str,
fromDomain = domain fromDomain = domain
fromDomainFull = getFullDomain(domain, port) fromDomainFull = getFullDomain(domain, port)
fromHttpPrefix = http_prefix fromHttpPrefix = http_prefix
if onionDomain: if onion_domain:
if toDomain.endswith('.onion'): if toDomain.endswith('.onion'):
fromDomain = onionDomain fromDomain = onion_domain
fromDomainFull = onionDomain fromDomainFull = onion_domain
fromHttpPrefix = 'http' fromHttpPrefix = 'http'
elif i2pDomain: elif i2pDomain:
if toDomain.endswith('.i2p'): if toDomain.endswith('.i2p'):
@ -3009,7 +3009,7 @@ def _sendToNamedAddresses(session, base_dir: str,
def sendToNamedAddressesThread(session, base_dir: str, def sendToNamedAddressesThread(session, base_dir: str,
nickname: str, domain: str, nickname: str, domain: str,
onionDomain: str, i2pDomain: str, port: int, onion_domain: str, i2pDomain: str, port: int,
http_prefix: str, federationList: [], http_prefix: str, federationList: [],
sendThreads: [], postLog: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
@ -3024,7 +3024,7 @@ def sendToNamedAddressesThread(session, base_dir: str,
threadWithTrace(target=_sendToNamedAddresses, threadWithTrace(target=_sendToNamedAddresses,
args=(session, base_dir, args=(session, base_dir,
nickname, domain, nickname, domain,
onionDomain, i2pDomain, port, onion_domain, i2pDomain, port,
http_prefix, federationList, http_prefix, federationList,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, personCache, cachedWebfingers, personCache,
@ -3085,7 +3085,7 @@ def _sendingProfileUpdate(postJsonObject: {}) -> bool:
def sendToFollowers(session, base_dir: str, def sendToFollowers(session, base_dir: str,
nickname: str, nickname: str,
domain: str, domain: str,
onionDomain: str, i2pDomain: str, port: int, onion_domain: str, i2pDomain: str, port: int,
http_prefix: str, federationList: [], http_prefix: str, federationList: [],
sendThreads: [], postLog: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
@ -3174,9 +3174,9 @@ def sendToFollowers(session, base_dir: str,
# have an alt onion domain then use the alt # have an alt onion domain then use the alt
fromDomain = domain fromDomain = domain
fromHttpPrefix = http_prefix fromHttpPrefix = http_prefix
if onionDomain: if onion_domain:
if toDomain.endswith('.onion'): if toDomain.endswith('.onion'):
fromDomain = onionDomain fromDomain = onion_domain
fromHttpPrefix = 'http' fromHttpPrefix = 'http'
elif i2pDomain: elif i2pDomain:
if toDomain.endswith('.i2p'): if toDomain.endswith('.i2p'):
@ -3258,7 +3258,7 @@ def sendToFollowers(session, base_dir: str,
def sendToFollowersThread(session, base_dir: str, def sendToFollowersThread(session, base_dir: str,
nickname: str, nickname: str,
domain: str, domain: str,
onionDomain: str, i2pDomain: str, port: int, onion_domain: str, i2pDomain: str, port: int,
http_prefix: str, federationList: [], http_prefix: str, federationList: [],
sendThreads: [], postLog: [], sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {}, cachedWebfingers: {}, personCache: {},
@ -3273,7 +3273,7 @@ def sendToFollowersThread(session, base_dir: str,
threadWithTrace(target=sendToFollowers, threadWithTrace(target=sendToFollowers,
args=(session, base_dir, args=(session, base_dir,
nickname, domain, nickname, domain,
onionDomain, i2pDomain, port, onion_domain, i2pDomain, port,
http_prefix, federationList, http_prefix, federationList,
sendThreads, postLog, sendThreads, postLog,
cachedWebfingers, personCache, cachedWebfingers, personCache,

View File

@ -100,7 +100,7 @@ def _updatePostSchedule(base_dir: str, handle: str, httpd,
httpd.http_prefix, httpd.http_prefix,
httpd.domain, httpd.domain,
httpd.domainFull, httpd.domainFull,
httpd.onionDomain, httpd.onion_domain,
httpd.i2pDomain, httpd.i2pDomain,
httpd.port, httpd.port,
httpd.recentPostsCache, httpd.recentPostsCache,

View File

@ -777,7 +777,7 @@ def createServerAlice(path: str, domain: str, port: int,
testServerAliceRunning = True testServerAliceRunning = True
maxMentions = 10 maxMentions = 10
maxEmoji = 10 maxEmoji = 10
onionDomain = None onion_domain = None
i2pDomain = None i2pDomain = None
allow_local_network_access = True allow_local_network_access = True
max_newswire_posts = 20 max_newswire_posts = 20
@ -814,7 +814,7 @@ def createServerAlice(path: str, domain: str, port: int,
0, False, 1, False, False, False, 0, False, 1, False, False, False,
5, True, True, 'en', __version__, 5, True, True, 'en', __version__,
"instance_id", False, path, domain, "instance_id", False, path, domain,
onionDomain, i2pDomain, None, None, port, port, onion_domain, i2pDomain, None, None, port, port,
http_prefix, federationList, maxMentions, maxEmoji, False, http_prefix, federationList, maxMentions, maxEmoji, False,
proxyType, maxReplies, proxyType, maxReplies,
domainMaxPostsPerDay, accountMaxPostsPerDay, domainMaxPostsPerDay, accountMaxPostsPerDay,
@ -919,7 +919,7 @@ def createServerBob(path: str, domain: str, port: int,
testServerBobRunning = True testServerBobRunning = True
maxMentions = 10 maxMentions = 10
maxEmoji = 10 maxEmoji = 10
onionDomain = None onion_domain = None
i2pDomain = None i2pDomain = None
allow_local_network_access = True allow_local_network_access = True
max_newswire_posts = 20 max_newswire_posts = 20
@ -956,7 +956,7 @@ def createServerBob(path: str, domain: str, port: int,
False, 1, False, False, False, False, 1, False, False, False,
5, True, True, 'en', __version__, 5, True, True, 'en', __version__,
"instance_id", False, path, domain, "instance_id", False, path, domain,
onionDomain, i2pDomain, None, None, port, port, onion_domain, i2pDomain, None, None, port, port,
http_prefix, federationList, maxMentions, maxEmoji, False, http_prefix, federationList, maxMentions, maxEmoji, False,
proxyType, maxReplies, proxyType, maxReplies,
domainMaxPostsPerDay, accountMaxPostsPerDay, domainMaxPostsPerDay, accountMaxPostsPerDay,
@ -988,7 +988,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
testServerEveRunning = True testServerEveRunning = True
maxMentions = 10 maxMentions = 10
maxEmoji = 10 maxEmoji = 10
onionDomain = None onion_domain = None
i2pDomain = None i2pDomain = None
allow_local_network_access = True allow_local_network_access = True
max_newswire_posts = 20 max_newswire_posts = 20
@ -1026,7 +1026,7 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
False, 1, False, False, False, False, 1, False, False, False,
5, True, True, 'en', __version__, 5, True, True, 'en', __version__,
"instance_id", False, path, domain, "instance_id", False, path, domain,
onionDomain, i2pDomain, None, None, port, port, onion_domain, i2pDomain, None, None, port, port,
http_prefix, federationList, maxMentions, maxEmoji, False, http_prefix, federationList, maxMentions, maxEmoji, False,
proxyType, maxReplies, allowDeletion, True, True, False, proxyType, maxReplies, allowDeletion, True, True, False,
sendThreads, False) sendThreads, False)
@ -1060,7 +1060,7 @@ def createServerGroup(path: str, domain: str, port: int,
testServerGroupRunning = True testServerGroupRunning = True
maxMentions = 10 maxMentions = 10
maxEmoji = 10 maxEmoji = 10
onionDomain = None onion_domain = None
i2pDomain = None i2pDomain = None
allow_local_network_access = True allow_local_network_access = True
max_newswire_posts = 20 max_newswire_posts = 20
@ -1098,7 +1098,7 @@ def createServerGroup(path: str, domain: str, port: int,
0, False, 1, False, False, False, 0, False, 1, False, False, False,
5, True, True, 'en', __version__, 5, True, True, 'en', __version__,
"instance_id", False, path, domain, "instance_id", False, path, domain,
onionDomain, i2pDomain, None, None, port, port, onion_domain, i2pDomain, None, None, port, port,
http_prefix, federationList, maxMentions, maxEmoji, False, http_prefix, federationList, maxMentions, maxEmoji, False,
proxyType, maxReplies, proxyType, maxReplies,
domainMaxPostsPerDay, accountMaxPostsPerDay, domainMaxPostsPerDay, accountMaxPostsPerDay,

View File

@ -684,7 +684,7 @@ def loadJson(filename: str, delaySec: int = 2, maxTries: int = 5) -> {}:
return jsonObject return jsonObject
def loadJsonOnionify(filename: str, domain: str, onionDomain: str, def loadJsonOnionify(filename: str, domain: str, onion_domain: str,
delaySec: int = 2) -> {}: delaySec: int = 2) -> {}:
"""Makes a few attempts to load a json formatted file """Makes a few attempts to load a json formatted file
This also converts the domain name to the onion domain This also converts the domain name to the onion domain
@ -696,7 +696,7 @@ def loadJsonOnionify(filename: str, domain: str, onionDomain: str,
with open(filename, 'r') as fp: with open(filename, 'r') as fp:
data = fp.read() data = fp.read()
if data: if data:
data = data.replace(domain, onionDomain) data = data.replace(domain, onion_domain)
data = data.replace('https:', 'http:') data = data.replace('https:', 'http:')
print('*****data: ' + data) print('*****data: ' + data)
jsonObject = json.loads(data) jsonObject = json.loads(data)

View File

@ -16,7 +16,7 @@ from markdown import markdownToHtml
def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str, def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str,
domainFull: str, onionDomain: str, translate: {}, domainFull: str, onion_domain: str, translate: {},
systemLanguage: str) -> str: systemLanguage: str) -> str:
"""Show the about screen """Show the about screen
""" """
@ -47,11 +47,11 @@ def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str,
http_prefix, domainFull, http_prefix, domainFull,
systemLanguage) systemLanguage)
aboutForm += '<div class="container">' + aboutText + '</div>' aboutForm += '<div class="container">' + aboutText + '</div>'
if onionDomain: if onion_domain:
aboutForm += \ aboutForm += \
'<div class="container"><center>\n' + \ '<div class="container"><center>\n' + \
'<p class="administeredby">' + \ '<p class="administeredby">' + \
'http://' + onionDomain + '</p>\n</center></div>\n' 'http://' + onion_domain + '</p>\n</center></div>\n'
if adminNickname: if adminNickname:
adminActor = '/users/' + adminNickname adminActor = '/users/' + adminNickname
aboutForm += \ aboutForm += \

View File

@ -215,7 +215,7 @@ def webfingerMeta(http_prefix: str, domainFull: str) -> str:
def webfingerLookup(path: str, base_dir: str, def webfingerLookup(path: str, base_dir: str,
domain: str, onionDomain: str, domain: str, onion_domain: str,
port: int, debug: bool) -> {}: port: int, debug: bool) -> {}:
"""Lookup the webfinger endpoint for an account """Lookup the webfinger endpoint for an account
""" """
@ -253,9 +253,9 @@ def webfingerLookup(path: str, base_dir: str,
# if this is a lookup for a handle using its onion domain # if this is a lookup for a handle using its onion domain
# then swap the onion domain for the clearnet version # then swap the onion domain for the clearnet version
onionify = False onionify = False
if onionDomain: if onion_domain:
if onionDomain in handle: if onion_domain in handle:
handle = handle.replace(onionDomain, domain) handle = handle.replace(onion_domain, domain)
onionify = True onionify = True
# instance actor # instance actor
if handle.startswith('actor@'): if handle.startswith('actor@'):
@ -273,7 +273,7 @@ def webfingerLookup(path: str, base_dir: str,
wfJson = loadJson(filename) wfJson = loadJson(filename)
else: else:
print('Webfinger request for onionified ' + handle) print('Webfinger request for onionified ' + handle)
wfJson = loadJsonOnionify(filename, domain, onionDomain) wfJson = loadJsonOnionify(filename, domain, onion_domain)
if not wfJson: if not wfJson:
wfJson = {"nickname": "unknown"} wfJson = {"nickname": "unknown"}
return wfJson return wfJson
@ -421,7 +421,7 @@ def _webfingerUpdateFromProfile(wfJson: {}, actorJson: {}) -> bool:
def webfingerUpdate(base_dir: str, nickname: str, domain: str, def webfingerUpdate(base_dir: str, nickname: str, domain: str,
onionDomain: str, onion_domain: str,
cachedWebfingers: {}) -> None: cachedWebfingers: {}) -> None:
handle = nickname + '@' + domain handle = nickname + '@' + domain
wfSubdir = '/wfendpoints' wfSubdir = '/wfendpoints'
@ -430,14 +430,14 @@ def webfingerUpdate(base_dir: str, nickname: str, domain: str,
filename = base_dir + wfSubdir + '/' + handle + '.json' filename = base_dir + wfSubdir + '/' + handle + '.json'
onionify = False onionify = False
if onionDomain: if onion_domain:
if onionDomain in handle: if onion_domain in handle:
handle = handle.replace(onionDomain, domain) handle = handle.replace(onion_domain, domain)
onionify = True onionify = True
if not onionify: if not onionify:
wfJson = loadJson(filename) wfJson = loadJson(filename)
else: else:
wfJson = loadJsonOnionify(filename, domain, onionDomain) wfJson = loadJsonOnionify(filename, domain, onion_domain)
if not wfJson: if not wfJson:
return return