Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 18:17:37 +00:00
parent 1b64e604ca
commit b8a3176154
22 changed files with 77 additions and 76 deletions

View File

@ -9,7 +9,7 @@ __module_group__ = "ActivityPub"
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_group_type from utils import has_group_type
from utils import removeDomainPort from utils import remove_domain_port
from utils import removeIdEnding from utils import removeIdEnding
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
@ -133,7 +133,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
if not urlPermitted(objectUrl, federation_list): if not urlPermitted(objectUrl, federation_list):
return None return None
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
fullDomain = get_full_domain(domain, port) fullDomain = get_full_domain(domain, port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -408,7 +408,7 @@ def outboxUndoAnnounce(recentPostsCache: {},
print('DEBUG: c2s undo announce request arrived in outbox') print('DEBUG: c2s undo announce request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = removeIdEnding(message_json['object']['object'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:

View File

@ -14,7 +14,7 @@ from datetime import datetime
from utils import has_object_string from utils import has_object_string
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_object_stringType from utils import has_object_stringType
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_object_dict from utils import has_object_dict
from utils import isAccountDir from utils import isAccountDir
from utils import getCachedPostFilename from utils import getCachedPostFilename
@ -79,7 +79,7 @@ def addBlock(base_dir: str, nickname: str, domain: str,
# don't block self # don't block self
return False return False
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
blockingFilename = acct_dir(base_dir, nickname, domain) + '/blocking.txt' blockingFilename = acct_dir(base_dir, nickname, domain) + '/blocking.txt'
blockHandle = blockNickname + '@' + blockDomain blockHandle = blockNickname + '@' + blockDomain
if os.path.isfile(blockingFilename): if os.path.isfile(blockingFilename):
@ -202,7 +202,7 @@ def removeBlock(base_dir: str, nickname: str, domain: str,
unblockNickname: str, unblockDomain: str) -> bool: unblockNickname: str, unblockDomain: str) -> bool:
"""Unblock the given account """Unblock the given account
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
unblockingFilename = acct_dir(base_dir, nickname, domain) + '/blocking.txt' unblockingFilename = acct_dir(base_dir, nickname, domain) + '/blocking.txt'
unblockHandle = unblockNickname + '@' + unblockDomain unblockHandle = unblockNickname + '@' + unblockDomain
if os.path.isfile(unblockingFilename): if os.path.isfile(unblockingFilename):
@ -441,7 +441,7 @@ def outboxBlock(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s block object has no nickname') print('DEBUG: c2s block object has no nickname')
return False return False
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:
@ -497,7 +497,7 @@ def outboxUndoBlock(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s undo block object has no nickname') print('DEBUG: c2s undo block object has no nickname')
return return
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:
@ -797,7 +797,7 @@ def outboxMute(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s mute object has no nickname') print('DEBUG: c2s mute object has no nickname')
return return
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:
@ -852,7 +852,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: c2s undo mute object has no nickname') print('DEBUG: c2s undo mute object has no nickname')
return return
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:

View File

@ -11,7 +11,7 @@ import os
from pprint import pprint from pprint import pprint
from webfinger import webfingerHandle from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
@ -592,7 +592,7 @@ def outboxBookmark(recentPostsCache: {},
print('DEBUG: c2s bookmark Add request arrived in outbox') print('DEBUG: c2s bookmark Add request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = removeIdEnding(message_json['object']['url'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageUrl) postFilename = locatePost(base_dir, nickname, domain, messageUrl)
if not postFilename: if not postFilename:
if debug: if debug:
@ -648,7 +648,7 @@ def outboxUndoBookmark(recentPostsCache: {},
print('DEBUG: c2s unbookmark Remove request arrived in outbox') print('DEBUG: c2s unbookmark Remove request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = removeIdEnding(message_json['object']['url'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageUrl) postFilename = locatePost(base_dir, nickname, domain, messageUrl)
if not postFilename: if not postFilename:
if debug: if debug:

View File

@ -12,7 +12,7 @@ import email.parser
import urllib.parse import urllib.parse
from shutil import copyfile from shutil import copyfile
from utils import dangerousSVG from utils import dangerousSVG
from utils import removeDomainPort from utils import remove_domain_port
from utils import isValidLanguage from utils import isValidLanguage
from utils import get_image_extensions from utils import get_image_extensions
from utils import load_json from utils import load_json
@ -855,7 +855,7 @@ def addHtmlTags(base_dir: str, http_prefix: str,
replaceEmoji = {} replaceEmoji = {}
emojiDict = {} emojiDict = {}
originalDomain = domain originalDomain = domain
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
followingFilename = acct_dir(base_dir, nickname, domain) + '/following.txt' followingFilename = acct_dir(base_dir, nickname, domain) + '/following.txt'
# read the following list so that we can detect just @nick # read the following list so that we can detect just @nick

View File

@ -10,7 +10,7 @@ __module_group__ = "ActivityPub"
import os import os
from datetime import datetime from datetime import datetime
from utils import has_object_string from utils import has_object_string
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
@ -154,7 +154,7 @@ def outboxDelete(base_dir: str, http_prefix: str,
"wasn't created by you (nickname does not match)") "wasn't created by you (nickname does not match)")
return return
deleteDomain, deletePort = getDomainFromActor(messageId) deleteDomain, deletePort = getDomainFromActor(messageId)
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
if deleteDomain != domain: if deleteDomain != domain:
if debug: if debug:
print("DEBUG: you can't delete a post which " + print("DEBUG: you can't delete a post which " +

View File

@ -65,7 +65,7 @@ from tests import testUpdateActor
from tests import runAllTests from tests import runAllTests
from auth import storeBasicCredentials from auth import storeBasicCredentials
from auth import createPassword from auth import createPassword
from utils import removeDomainPort from utils import remove_domain_port
from utils import get_port_from_domain from utils import get_port_from_domain
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
@ -1278,7 +1278,7 @@ if args.message:
toPort = 443 toPort = 443
if ':' in toDomain: if ':' in toDomain:
toPort = get_port_from_domain(toDomain) toPort = get_port_from_domain(toDomain)
toDomain = removeDomainPort(toDomain) toDomain = remove_domain_port(toDomain)
else: else:
if args.sendto.endswith('followers'): if args.sendto.endswith('followers'):
toNickname = None toNickname = None

View File

@ -11,7 +11,7 @@ from pprint import pprint
import os import os
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_object_stringType from utils import has_object_stringType
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
from utils import getFollowersList from utils import getFollowersList
@ -169,7 +169,7 @@ def isFollowingActor(base_dir: str,
"""Is the given nickname following the given actor? """Is the given nickname following the given actor?
The actor can also be a handle: nickname@domain The actor can also be a handle: nickname@domain
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
if not os.path.isdir(base_dir + '/accounts/' + handle): if not os.path.isdir(base_dir + '/accounts/' + handle):
return False return False
@ -221,7 +221,7 @@ def followerOfPerson(base_dir: str, nickname: str, domain: str,
def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []: def getFollowerDomains(base_dir: str, nickname: str, domain: str) -> []:
"""Returns a list of domains for followers """Returns a list of domains for followers
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
followersFile = acct_dir(base_dir, nickname, domain) + '/followers.txt' followersFile = acct_dir(base_dir, nickname, domain) + '/followers.txt'
if not os.path.isfile(followersFile): if not os.path.isfile(followersFile):
return [] return []
@ -254,7 +254,7 @@ def isFollowerOfPerson(base_dir: str, nickname: str, domain: str,
if not followerNickname: if not followerNickname:
print('No followerNickname for ' + followerDomain) print('No followerNickname for ' + followerDomain)
return False return False
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
followersFile = acct_dir(base_dir, nickname, domain) + '/followers.txt' followersFile = acct_dir(base_dir, nickname, domain) + '/followers.txt'
if not os.path.isfile(followersFile): if not os.path.isfile(followersFile):
return False return False
@ -288,7 +288,7 @@ def unfollowAccount(base_dir: str, nickname: str, domain: str,
followFile: str = 'following.txt') -> bool: followFile: str = 'following.txt') -> bool:
"""Removes a person to the follow list """Removes a person to the follow list
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
handleToUnfollow = followNickname + '@' + followDomain handleToUnfollow = followNickname + '@' + followDomain
if group_account: if group_account:
@ -503,7 +503,7 @@ def getFollowingFeed(base_dir: str, domain: str, port: int, path: str,
} }
handleDomain = domain handleDomain = domain
handleDomain = removeDomainPort(handleDomain) handleDomain = remove_domain_port(handleDomain)
handle = nickname + '@' + handleDomain handle = nickname + '@' + handleDomain
filename = base_dir + '/accounts/' + handle + '/' + followFile + '.txt' filename = base_dir + '/accounts/' + handle + '/' + followFile + '.txt'
if not os.path.isfile(filename): if not os.path.isfile(filename):
@ -570,7 +570,7 @@ def followApprovalRequired(base_dir: str, nicknameToFollow: str,
return False return False
manuallyApproveFollows = False manuallyApproveFollows = False
domainToFollow = removeDomainPort(domainToFollow) domainToFollow = remove_domain_port(domainToFollow)
actorFilename = base_dir + '/accounts/' + \ actorFilename = base_dir + '/accounts/' + \
nicknameToFollow + '@' + domainToFollow + '.json' nicknameToFollow + '@' + domainToFollow + '.json'
if os.path.isfile(actorFilename): if os.path.isfile(actorFilename):

View File

@ -17,7 +17,7 @@ def _dirAcct(base_dir: str, nickname: str, domain: str) -> str:
def _portDomainRemove(domain: str) -> str: def _portDomainRemove(domain: str) -> str:
"""If the domain has a port appended then remove it """If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com eg. mydomain.com:80 becomes mydomain.com
same as removeDomainPort in utils.py same as remove_domain_port in utils.py
""" """
if ':' in domain: if ':' in domain:
if domain.startswith('did:'): if domain.startswith('did:'):

View File

@ -30,7 +30,7 @@ from utils import canReplyTo
from utils import get_user_paths from utils import get_user_paths
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import acct_dir from utils import acct_dir
from utils import removeDomainPort from utils import remove_domain_port
from utils import get_port_from_domain from utils import get_port_from_domain
from utils import has_object_dict from utils import has_object_dict
from utils import dmAllowedFromDomain from utils import dmAllowedFromDomain
@ -324,7 +324,7 @@ def _inboxStorePostToHtmlCache(recentPostsCache: {}, max_recent_posts: int,
def validInbox(base_dir: str, nickname: str, domain: str) -> bool: def validInbox(base_dir: str, nickname: str, domain: str) -> bool:
"""Checks whether files were correctly saved to the inbox """Checks whether files were correctly saved to the inbox
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
inboxDir = acct_dir(base_dir, nickname, domain) + '/inbox' inboxDir = acct_dir(base_dir, nickname, domain) + '/inbox'
if not os.path.isdir(inboxDir): if not os.path.isdir(inboxDir):
return True return True
@ -346,7 +346,7 @@ def validInboxFilenames(base_dir: str, nickname: str, domain: str,
"""Used by unit tests to check that the port number gets appended to """Used by unit tests to check that the port number gets appended to
domain names within saved post filenames domain names within saved post filenames
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
inboxDir = acct_dir(base_dir, nickname, domain) + '/inbox' inboxDir = acct_dir(base_dir, nickname, domain) + '/inbox'
if not os.path.isdir(inboxDir): if not os.path.isdir(inboxDir):
print('Not an inbox directory: ' + inboxDir) print('Not an inbox directory: ' + inboxDir)
@ -465,7 +465,7 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
str(len(messageBytes)) + ' bytes') str(len(messageBytes)) + ' bytes')
return None return None
originalDomain = domain originalDomain = domain
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
# block at the ealiest stage possible, which means the data # block at the ealiest stage possible, which means the data
# isn't written to file # isn't written to file
@ -644,7 +644,7 @@ def _inboxPostRecipients(base_dir: str, post_json_object: {},
print('WARNING: inbox post has no actor') print('WARNING: inbox post has no actor')
return recipientsDict, recipientsDictFollowers return recipientsDict, recipientsDictFollowers
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
domainBase = domain domainBase = domain
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)
domainMatch = '/' + domain + '/users/' domainMatch = '/' + domain + '/users/'
@ -1564,7 +1564,7 @@ def _receiveBookmark(recentPostsCache: {},
print('DEBUG: c2s inbox bookmark Add request arrived in outbox') print('DEBUG: c2s inbox bookmark Add request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = removeIdEnding(message_json['object']['url'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageUrl) postFilename = locatePost(base_dir, nickname, domain, messageUrl)
if not postFilename: if not postFilename:
if debug: if debug:
@ -1677,7 +1677,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
'request arrived in outbox') 'request arrived in outbox')
messageUrl = removeIdEnding(message_json['object']['url']) messageUrl = removeIdEnding(message_json['object']['url'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageUrl) postFilename = locatePost(base_dir, nickname, domain, messageUrl)
if not postFilename: if not postFilename:
if debug: if debug:
@ -2770,7 +2770,7 @@ def _updateLastSeen(base_dir: str, handle: str, actor: str) -> None:
return return
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
domain = handle.split('@')[1] domain = handle.split('@')[1]
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
accountPath = acct_dir(base_dir, nickname, domain) accountPath = acct_dir(base_dir, nickname, domain)
if not os.path.isdir(accountPath): if not os.path.isdir(accountPath):
return return
@ -2831,7 +2831,7 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
senderPort = port senderPort = port
if ':' in senderDomain: if ':' in senderDomain:
senderPort = get_port_from_domain(senderDomain) senderPort = get_port_from_domain(senderDomain)
senderDomain = removeDomainPort(senderDomain) senderDomain = remove_domain_port(senderDomain)
cc = [] cc = []
# create the bounce DM # create the bounce DM

View File

@ -12,7 +12,7 @@ from pprint import pprint
from utils import has_object_string from utils import has_object_string
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_object_stringType from utils import has_object_stringType
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_object_dict from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
@ -359,7 +359,7 @@ def outboxLike(recentPostsCache: {},
print('DEBUG: c2s like request arrived in outbox') print('DEBUG: c2s like request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = removeIdEnding(message_json['object'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:
@ -396,7 +396,7 @@ def outboxUndoLike(recentPostsCache: {},
print('DEBUG: c2s undo like request arrived in outbox') print('DEBUG: c2s undo like request arrived in outbox')
messageId = removeIdEnding(message_json['object']['object']) messageId = removeIdEnding(message_json['object']['object'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:

View File

@ -12,7 +12,7 @@ from follow import followedAccountAccepts
from follow import followedAccountRejects from follow import followedAccountRejects
from follow import removeFromFollowRequests from follow import removeFromFollowRequests
from utils import load_json from utils import load_json
from utils import removeDomainPort from utils import remove_domain_port
from utils import get_port_from_domain from utils import get_port_from_domain
from utils import get_user_paths from utils import get_user_paths
from utils import acct_dir from utils import acct_dir
@ -58,7 +58,7 @@ def manualDenyFollowRequest(session, base_dir: str,
denyPort = port denyPort = port
if ':' in denyDomain: if ':' in denyDomain:
denyPort = get_port_from_domain(denyDomain) denyPort = get_port_from_domain(denyDomain)
denyDomain = removeDomainPort(denyDomain) denyDomain = remove_domain_port(denyDomain)
followedAccountRejects(session, base_dir, http_prefix, followedAccountRejects(session, base_dir, http_prefix,
nickname, domain, port, nickname, domain, port,
denyNickname, denyDomain, denyPort, denyNickname, denyDomain, denyPort,
@ -202,7 +202,8 @@ def manualApproveFollowRequest(session, base_dir: str,
if ':' in approveDomain: if ':' in approveDomain:
approvePort = \ approvePort = \
get_port_from_domain(approveDomain) get_port_from_domain(approveDomain)
approveDomain = removeDomainPort(approveDomain) approveDomain = \
remove_domain_port(approveDomain)
print('Manual follow accept: Sending Accept for ' + print('Manual follow accept: Sending Accept for ' +
handle + ' follow request from ' + handle + ' follow request from ' +
approveNickname + '@' + approveDomain) approveNickname + '@' + approveDomain)

View File

@ -8,7 +8,7 @@ __status__ = "Production"
__module_group__ = "Calendar" __module_group__ = "Calendar"
import os import os
from utils import removeDomainPort from utils import remove_domain_port
from utils import acct_dir from utils import acct_dir
@ -20,7 +20,7 @@ def _notifyOnPostArrival(base_dir: str, nickname: str, domain: str,
indicating whether to notify when a new post arrives from that account indicating whether to notify when a new post arrives from that account
""" """
# check that a following file exists # check that a following file exists
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
followingFilename = acct_dir(base_dir, nickname, domain) + '/following.txt' followingFilename = acct_dir(base_dir, nickname, domain) + '/following.txt'
if not os.path.isfile(followingFilename): if not os.path.isfile(followingFilename):
print("WARN: following.txt doesn't exist for " + print("WARN: following.txt doesn't exist for " +

View File

@ -42,7 +42,7 @@ from utils import removeHtml
from utils import containsInvalidChars from utils import containsInvalidChars
from utils import replace_users_with_at from utils import replace_users_with_at
from utils import remove_line_endings from utils import remove_line_endings
from utils import removeDomainPort from utils import remove_domain_port
from utils import getStatusNumber from utils import getStatusNumber
from utils import get_full_domain from utils import get_full_domain
from utils import validNickname from utils import validNickname
@ -107,7 +107,7 @@ def setProfileImage(base_dir: str, http_prefix: str,
if image_filename.startswith('~/'): if image_filename.startswith('~/'):
image_filename = image_filename.replace('~/', str(Path.home()) + '/') image_filename = image_filename.replace('~/', str(Path.home()) + '/')
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
fullDomain = get_full_domain(domain, port) fullDomain = get_full_domain(domain, port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
@ -167,7 +167,7 @@ def setProfileImage(base_dir: str, http_prefix: str,
def _accountExists(base_dir: str, nickname: str, domain: str) -> bool: def _accountExists(base_dir: str, nickname: str, domain: str) -> bool:
"""Returns true if the given account exists """Returns true if the given account exists
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
accountDir = acct_dir(base_dir, nickname, domain) accountDir = acct_dir(base_dir, nickname, domain)
return os.path.isdir(accountDir) or \ return os.path.isdir(accountDir) or \
os.path.isdir(base_dir + '/deactivated/' + nickname + '@' + domain) os.path.isdir(base_dir + '/deactivated/' + nickname + '@' + domain)
@ -885,7 +885,7 @@ def personLookup(domain: str, path: str, base_dir: str) -> {}:
return None return None
if not isSharedInbox and not validNickname(domain, nickname): if not isSharedInbox and not validNickname(domain, nickname):
return None return None
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
filename = base_dir + '/accounts/' + handle + '.json' filename = base_dir + '/accounts/' + handle + '.json'
if not os.path.isfile(filename): if not os.path.isfile(filename):

View File

@ -39,7 +39,7 @@ from utils import removeIdEnding
from utils import replace_users_with_at from utils import replace_users_with_at
from utils import has_group_type from utils import has_group_type
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import removeDomainPort from utils import remove_domain_port
from utils import get_port_from_domain from utils import get_port_from_domain
from utils import has_object_dict from utils import has_object_dict
from utils import rejectPostId from utils import rejectPostId
@ -916,7 +916,7 @@ def savePostToBox(base_dir: str, http_prefix: str, postId: str,
boxname != 'scheduled': boxname != 'scheduled':
return None return None
originalDomain = domain originalDomain = domain
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
if not postId: if not postId:
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -2036,7 +2036,7 @@ def getMentionedPeople(base_dir: str, http_prefix: str,
mentionedNickname = handle.split('@')[0] mentionedNickname = handle.split('@')[0]
mentionedDomain = handle.split('@')[1].strip('\n').strip('\r') mentionedDomain = handle.split('@')[1].strip('\n').strip('\r')
if ':' in mentionedDomain: if ':' in mentionedDomain:
mentionedDomain = removeDomainPort(mentionedDomain) mentionedDomain = remove_domain_port(mentionedDomain)
if not validNickname(mentionedDomain, mentionedNickname): if not validNickname(mentionedDomain, mentionedNickname):
continue continue
actor = \ actor = \
@ -3172,7 +3172,7 @@ def sendToFollowers(session, base_dir: str,
toDomain = followerHandles[index].split('@')[1] toDomain = followerHandles[index].split('@')[1]
if ':' in toDomain: if ':' in toDomain:
toPort = get_port_from_domain(toDomain) toPort = get_port_from_domain(toDomain)
toDomain = removeDomainPort(toDomain) toDomain = remove_domain_port(toDomain)
cc = '' cc = ''

View File

@ -14,7 +14,7 @@ from pprint import pprint
from utils import has_object_string from utils import has_object_string
from utils import has_object_string_object from utils import has_object_string_object
from utils import has_object_stringType from utils import has_object_stringType
from utils import removeDomainPort from utils import remove_domain_port
from utils import has_object_dict from utils import has_object_dict
from utils import has_users_path from utils import has_users_path
from utils import get_full_domain from utils import get_full_domain
@ -382,7 +382,7 @@ def outboxReaction(recentPostsCache: {},
print('DEBUG: c2s reaction request arrived in outbox') print('DEBUG: c2s reaction request arrived in outbox')
messageId = removeIdEnding(message_json['object']) messageId = removeIdEnding(message_json['object'])
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
emojiContent = message_json['content'] emojiContent = message_json['content']
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -425,7 +425,7 @@ def outboxUndoReaction(recentPostsCache: {},
messageId = removeIdEnding(message_json['object']['object']) messageId = removeIdEnding(message_json['object']['object'])
emojiContent = message_json['object']['content'] emojiContent = message_json['object']['content']
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:

View File

@ -11,7 +11,7 @@ import os
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import getStatusNumber from utils import getStatusNumber
from utils import removeDomainPort from utils import remove_domain_port
from utils import acct_dir from utils import acct_dir
@ -78,7 +78,7 @@ def _addRole(base_dir: str, nickname: str, domain: str,
"""Adds a role nickname to the file. """Adds a role nickname to the file.
This is a file containing the nicknames of accounts having this role This is a file containing the nicknames of accounts having this role
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
roleFile = base_dir + '/accounts/' + roleFilename roleFile = base_dir + '/accounts/' + roleFilename
if os.path.isfile(roleFile): if os.path.isfile(roleFile):
# is this nickname already in the file? # is this nickname already in the file?

View File

@ -31,7 +31,7 @@ from utils import validNickname
from utils import load_json from utils import load_json
from utils import save_json from utils import save_json
from utils import get_image_extensions from utils import get_image_extensions
from utils import removeDomainPort from utils import remove_domain_port
from utils import isAccountDir from utils import isAccountDir
from utils import acct_dir from utils import acct_dir
from utils import is_float from utils import is_float
@ -415,7 +415,7 @@ def _expireSharesForAccount(base_dir: str, nickname: str, domain: str,
sharesFileType: str) -> None: sharesFileType: str) -> None:
"""Removes expired items from shares for a particular account """Removes expired items from shares for a particular account
""" """
handleDomain = removeDomainPort(domain) handleDomain = remove_domain_port(domain)
handle = nickname + '@' + handleDomain handle = nickname + '@' + handleDomain
sharesFilename = \ sharesFilename = \
base_dir + '/accounts/' + handle + '/' + sharesFileType + '.json' base_dir + '/accounts/' + handle + '/' + sharesFileType + '.json'
@ -488,7 +488,7 @@ def getSharesFeedForPerson(base_dir: str,
domain = get_full_domain(domain, port) domain = get_full_domain(domain, port)
handleDomain = removeDomainPort(domain) handleDomain = remove_domain_port(domain)
sharesFilename = \ sharesFilename = \
acct_dir(base_dir, nickname, handleDomain) + '/' + \ acct_dir(base_dir, nickname, handleDomain) + '/' + \
sharesFileType + '.json' sharesFileType + '.json'

View File

@ -573,7 +573,7 @@ def getFollowersOfPerson(base_dir: str,
Used by the shared inbox to know who to send incoming mail to Used by the shared inbox to know who to send incoming mail to
""" """
followers = [] followers = []
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
handle = nickname + '@' + domain handle = nickname + '@' + domain
if not os.path.isdir(base_dir + '/accounts/' + handle): if not os.path.isdir(base_dir + '/accounts/' + handle):
return followers return followers
@ -814,7 +814,7 @@ def createInboxQueueDir(nickname: str, domain: str, base_dir: str) -> str:
def domainPermitted(domain: str, federation_list: []): def domainPermitted(domain: str, federation_list: []):
if len(federation_list) == 0: if len(federation_list) == 0:
return True return True
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
if domain in federation_list: if domain in federation_list:
return True return True
return False return False
@ -1098,7 +1098,7 @@ def getDomainFromActor(actor: str) -> (str, int):
domain = domain.split('/')[0] domain = domain.split('/')[0]
if ':' in domain: if ':' in domain:
port = get_port_from_domain(domain) port = get_port_from_domain(domain)
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
return domain, port return domain, port
@ -1107,7 +1107,7 @@ def _setDefaultPetName(base_dir: str, nickname: str, domain: str,
"""Sets a default petname """Sets a default petname
This helps especially when using onion or i2p address This helps especially when using onion or i2p address
""" """
domain = removeDomainPort(domain) domain = remove_domain_port(domain)
userPath = acct_dir(base_dir, nickname, domain) userPath = acct_dir(base_dir, nickname, domain)
petnamesFilename = userPath + '/petnames.txt' petnamesFilename = userPath + '/petnames.txt'
@ -1150,7 +1150,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
print('DEBUG: follow of domain ' + followDomain) print('DEBUG: follow of domain ' + followDomain)
if ':' in domain: if ':' in domain:
domainOnly = removeDomainPort(domain) domainOnly = remove_domain_port(domain)
handle = nickname + '@' + domainOnly handle = nickname + '@' + domainOnly
else: else:
handle = nickname + '@' + domain handle = nickname + '@' + domain
@ -1160,7 +1160,7 @@ def followPerson(base_dir: str, nickname: str, domain: str,
return False return False
if ':' in followDomain: if ':' in followDomain:
followDomainOnly = removeDomainPort(followDomain) followDomainOnly = remove_domain_port(followDomain)
handleToFollow = followNickname + '@' + followDomainOnly handleToFollow = followNickname + '@' + followDomainOnly
else: else:
handleToFollow = followNickname + '@' + followDomain handleToFollow = followNickname + '@' + followDomain
@ -2909,7 +2909,7 @@ def getActorPropertyUrl(actor_json: {}, propertyName: str) -> str:
return '' return ''
def removeDomainPort(domain: str) -> str: def remove_domain_port(domain: str) -> str:
"""If the domain has a port appended then remove it """If the domain has a port appended then remove it
eg. mydomain.com:80 becomes mydomain.com eg. mydomain.com:80 becomes mydomain.com
""" """

View File

@ -18,7 +18,7 @@ from utils import locatePost
from utils import load_json from utils import load_json
from utils import weekDayOfMonthStart from utils import weekDayOfMonthStart
from utils import getAltPath from utils import getAltPath
from utils import removeDomainPort from utils import remove_domain_port
from utils import acct_dir from utils import acct_dir
from utils import local_actor_url from utils import local_actor_url
from utils import replace_users_with_at from utils import replace_users_with_at
@ -249,7 +249,7 @@ def htmlCalendar(person_cache: {}, cssCache: {}, translate: {},
text_mode_banner: str, accessKeys: {}) -> str: text_mode_banner: str, accessKeys: {}) -> str:
"""Show the calendar for a person """Show the calendar for a person
""" """
domain = removeDomainPort(domain_full) domain = remove_domain_port(domain_full)
monthNumber = 0 monthNumber = 0
dayNumber = None dayNumber = None

View File

@ -12,7 +12,7 @@ from utils import get_config_param
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import is_editor from utils import is_editor
from utils import is_artist from utils import is_artist
from utils import removeDomainPort from utils import remove_domain_port
from utils import local_actor_url from utils import local_actor_url
from webapp_utils import sharesTimelineJson from webapp_utils import sharesTimelineJson
from webapp_utils import htmlPostSeparator from webapp_utils import htmlPostSeparator
@ -125,7 +125,7 @@ def getLeftColumnContent(base_dir: str, nickname: str, domain_full: str,
htmlStr = '' htmlStr = ''
separatorStr = htmlPostSeparator(base_dir, 'left') separatorStr = htmlPostSeparator(base_dir, 'left')
domain = removeDomainPort(domain_full) domain = remove_domain_port(domain_full)
editImageClass = '' editImageClass = ''
if showHeaderImage: if showHeaderImage:
@ -374,7 +374,7 @@ def htmlLinksMobile(cssCache: {}, base_dir: str,
editor = is_editor(base_dir, nickname) editor = is_editor(base_dir, nickname)
artist = is_artist(base_dir, nickname) artist = is_artist(base_dir, nickname)
domain = removeDomainPort(domain_full) domain = remove_domain_port(domain_full)
instanceTitle = \ instanceTitle = \
get_config_param(base_dir, 'instanceTitle') get_config_param(base_dir, 'instanceTitle')

View File

@ -20,7 +20,7 @@ from utils import votesOnNewswireItem
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import is_editor from utils import is_editor
from utils import get_config_param from utils import get_config_param
from utils import removeDomainPort from utils import remove_domain_port
from utils import acct_dir from utils import acct_dir
from posts import isModerator from posts import isModerator
from newswire import getNewswireFaviconUrl from newswire import getNewswireFaviconUrl
@ -65,7 +65,7 @@ def getRightColumnContent(base_dir: str, nickname: str, domain_full: str,
""" """
htmlStr = '' htmlStr = ''
domain = removeDomainPort(domain_full) domain = remove_domain_port(domain_full)
if authorized: if authorized:
# only show the publish button if logged in, otherwise replace it with # only show the publish button if logged in, otherwise replace it with

View File

@ -17,7 +17,7 @@ from utils import load_json
from utils import load_json_onionify from utils import load_json_onionify
from utils import save_json from utils import save_json
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import removeDomainPort from utils import remove_domain_port
from utils import get_user_paths from utils import get_user_paths
from utils import get_group_paths from utils import get_group_paths
from utils import local_actor_url from utils import local_actor_url
@ -75,7 +75,7 @@ def webfingerHandle(session, handle: str, http_prefix: str,
nickname, domain, grpAccount = _parseHandle(handle) nickname, domain, grpAccount = _parseHandle(handle)
if not nickname: if not nickname:
return None return None
wfDomain = removeDomainPort(domain) wfDomain = remove_domain_port(domain)
wfHandle = nickname + '@' + wfDomain wfHandle = nickname + '@' + wfDomain
wf = getWebfingerFromCache(wfHandle, cached_webfingers) wf = getWebfingerFromCache(wfHandle, cached_webfingers)