Snake case

merge-requests/30/head
Bob Mottram 2021-12-26 12:45:03 +00:00
parent f586d1bf66
commit 79dabfa8fc
35 changed files with 225 additions and 218 deletions

View File

@ -10,7 +10,7 @@ __module_group__ = "ActivityPub"
import os import os
from utils import hasObjectStringObject from utils import hasObjectStringObject
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import urlPermitted from utils import urlPermitted
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -39,7 +39,7 @@ def _create_accept_reject(base_dir: str, federation_list: [],
if not urlPermitted(objectJson['actor'], federation_list): if not urlPermitted(objectJson['actor'], federation_list):
return None return None
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
new_accept = { new_accept = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",

View File

@ -12,7 +12,7 @@ from utils import hasGroupType
from utils import removeDomainPort from utils import removeDomainPort
from utils import removeIdEnding from utils import removeIdEnding
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import getStatusNumber from utils import getStatusNumber
from utils import createOutboxDir from utils import createOutboxDir
from utils import urlPermitted from utils import urlPermitted
@ -134,7 +134,7 @@ def createAnnounce(session, base_dir: str, federation_list: [],
return None return None
domain = removeDomainPort(domain) domain = removeDomainPort(domain)
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
newAnnounceId = http_prefix + '://' + fullDomain + \ newAnnounceId = http_prefix + '://' + fullDomain + \
@ -195,7 +195,7 @@ def announcePublic(session, base_dir: str, federation_list: [],
signing_priv_key_pem: str) -> {}: signing_priv_key_pem: str) -> {}:
"""Makes a public announcement """Makes a public announcement
""" """
fromDomain = getFullDomain(domain, port) fromDomain = get_full_domain(domain, port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = local_actor_url(http_prefix, nickname, fromDomain) + '/followers' ccUrl = local_actor_url(http_prefix, nickname, fromDomain) + '/followers'
@ -222,7 +222,7 @@ def sendAnnounceViaServer(base_dir: str, session,
print('WARN: No session for sendAnnounceViaServer') print('WARN: No session for sendAnnounceViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
actorStr = local_actor_url(http_prefix, fromNickname, fromDomainFull) actorStr = local_actor_url(http_prefix, fromNickname, fromDomainFull)
@ -315,7 +315,7 @@ def sendUndoAnnounceViaServer(base_dir: str, session,
print('WARN: No session for sendUndoAnnounceViaServer') print('WARN: No session for sendUndoAnnounceViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
handle = replaceUsersWithAt(actor) handle = replaceUsersWithAt(actor)

View File

@ -13,7 +13,7 @@ from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import hasObjectString from utils import hasObjectString
from utils import getFullDomain from utils import get_full_domain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -90,7 +90,7 @@ def sendAvailabilityViaServer(base_dir: str, session,
print('WARN: No session for sendAvailabilityViaServer') print('WARN: No session for sendAvailabilityViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
toUrl = local_actor_url(http_prefix, nickname, domain_full) toUrl = local_actor_url(http_prefix, nickname, domain_full)
ccUrl = toUrl + '/followers' ccUrl = toUrl + '/followers'

View File

@ -23,7 +23,7 @@ from utils import saveJson
from utils import fileLastModified from utils import fileLastModified
from utils import setConfigParam from utils import setConfigParam
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import isEvil from utils import isEvil
from utils import locatePost from utils import locatePost
@ -453,7 +453,7 @@ def outboxBlock(base_dir: str, http_prefix: str,
print('WARN: unable to find nickname in ' + message_json['object']) print('WARN: unable to find nickname in ' + message_json['object'])
return False return False
domainBlocked, portBlocked = getDomainFromActor(message_json['object']) domainBlocked, portBlocked = getDomainFromActor(message_json['object'])
domainBlockedFull = getFullDomain(domainBlocked, portBlocked) domainBlockedFull = get_full_domain(domainBlocked, portBlocked)
addBlock(base_dir, nickname, domain, addBlock(base_dir, nickname, domain,
nicknameBlocked, domainBlockedFull) nicknameBlocked, domainBlockedFull)
@ -511,7 +511,7 @@ def outboxUndoBlock(base_dir: str, http_prefix: str,
return return
domainObject = message_json['object']['object'] domainObject = message_json['object']['object']
domainBlocked, portBlocked = getDomainFromActor(domainObject) domainBlocked, portBlocked = getDomainFromActor(domainObject)
domainBlockedFull = getFullDomain(domainBlocked, portBlocked) domainBlockedFull = get_full_domain(domainBlocked, portBlocked)
removeBlock(base_dir, nickname, domain, removeBlock(base_dir, nickname, domain,
nicknameBlocked, domainBlockedFull) nicknameBlocked, domainBlockedFull)
@ -543,7 +543,7 @@ def mutePost(base_dir: str, nickname: str, domain: str, port: int,
if hasObjectString(post_json_object, debug): if hasObjectString(post_json_object, debug):
alsoUpdatePostId = removeIdEnding(post_json_object['object']) alsoUpdatePostId = removeIdEnding(post_json_object['object'])
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
if postJsonObj.get('conversation'): if postJsonObj.get('conversation'):
@ -687,7 +687,7 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj['conversation']) postJsonObj['conversation'])
if postJsonObj.get('ignores'): if postJsonObj.get('ignores'):
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
totalItems = 0 totalItems = 0
if postJsonObj['ignores'].get('totalItems'): if postJsonObj['ignores'].get('totalItems'):
@ -778,7 +778,7 @@ def outboxMute(base_dir: str, http_prefix: str,
return return
if not hasActor(message_json, debug): if not hasActor(message_json, debug):
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
return return
if not message_json['type'] == 'Ignore': if not message_json['type'] == 'Ignore':
@ -827,7 +827,7 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
return return
if not hasActor(message_json, debug): if not hasActor(message_json, debug):
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
return return
if not message_json['type'] == 'Undo': if not message_json['type'] == 'Undo':

10
blog.py
View File

@ -24,7 +24,7 @@ from utils import get_content_from_post
from utils import isAccountDir from utils import isAccountDir
from utils import removeHtml from utils import removeHtml
from utils import getConfigParam from utils import getConfigParam
from utils import getFullDomain from utils import get_full_domain
from utils import getMediaFormats from utils import getMediaFormats
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -538,7 +538,7 @@ def htmlBlogPage(authorized: bool, session,
if not timelineJson: if not timelineJson:
return blogStr + htmlFooter() return blogStr + htmlFooter()
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# show previous and next buttons # show previous and next buttons
if pageNumber is not None: if pageNumber is not None:
@ -608,7 +608,7 @@ def htmlBlogPageRSS2(authorized: bool, session,
'\n' in nickname or '\r' in nickname: '\n' in nickname or '\r' in nickname:
return None return None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
blogRSS2 = '' blogRSS2 = ''
if includeHeader: if includeHeader:
@ -663,7 +663,7 @@ def htmlBlogPageRSS3(authorized: bool, session,
'\n' in nickname or '\r' in nickname: '\n' in nickname or '\r' in nickname:
return None return None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
blogRSS3 = '' blogRSS3 = ''
@ -753,7 +753,7 @@ def htmlBlogView(authorized: bool,
noOfItems, 1, peertube_instances, noOfItems, 1, peertube_instances,
system_language, person_cache, debug) system_language, person_cache, debug)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
for subdir, dirs, files in os.walk(base_dir + '/accounts'): for subdir, dirs, files in os.walk(base_dir + '/accounts'):
for acct in dirs: for acct in dirs:

View File

@ -13,7 +13,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from utils import removeDomainPort from utils import removeDomainPort
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import removePostFromCache from utils import removePostFromCache
from utils import urlPermitted from utils import urlPermitted
@ -265,7 +265,7 @@ def bookmark(recentPostsCache: {},
if not urlPermitted(objectUrl, federation_list): if not urlPermitted(objectUrl, federation_list):
return None return None
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
newBookmarkJson = { newBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -324,7 +324,7 @@ def undoBookmark(recentPostsCache: {},
if not urlPermitted(objectUrl, federation_list): if not urlPermitted(objectUrl, federation_list):
return None return None
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
newUndoBookmarkJson = { newUndoBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -383,7 +383,7 @@ def sendBookmarkViaServer(base_dir: str, session,
print('WARN: No session for sendBookmarkViaServer') print('WARN: No session for sendBookmarkViaServer')
return 6 return 6
domain_full = getFullDomain(domain, fromPort) domain_full = get_full_domain(domain, fromPort)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
@ -473,7 +473,7 @@ def sendUndoBookmarkViaServer(base_dir: str, session,
print('WARN: No session for sendUndoBookmarkViaServer') print('WARN: No session for sendUndoBookmarkViaServer')
return 6 return 6
domain_full = getFullDomain(domain, fromPort) domain_full = get_full_domain(domain, fromPort)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
@ -572,7 +572,7 @@ def outboxBookmark(recentPostsCache: {},
if debug: if debug:
print('DEBUG: bookmark Add target is not string') print('DEBUG: bookmark Add target is not string')
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['target'].endswith('://' + domain_full + if not message_json['target'].endswith('://' + domain_full +
'/users/' + nickname + '/users/' + nickname +
'/tlbookmarks'): '/tlbookmarks'):
@ -628,7 +628,7 @@ def outboxUndoBookmark(recentPostsCache: {},
if debug: if debug:
print('DEBUG: unbookmark Remove target is not string') print('DEBUG: unbookmark Remove target is not string')
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if not message_json['target'].endswith('://' + domain_full + if not message_json['target'].endswith('://' + domain_full +
'/users/' + nickname + '/users/' + nickname +
'/tlbookmarks'): '/tlbookmarks'):

View File

@ -272,7 +272,7 @@ from utils import decoded_host
from utils import isPublicPost from utils import isPublicPost
from utils import get_locked_account from utils import get_locked_account
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import removeHtml from utils import removeHtml
from utils import isEditor from utils import isEditor
from utils import isArtist from utils import isArtist
@ -1969,7 +1969,8 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain # https://domain
blockDomain, blockPort = \ blockDomain, blockPort = \
getDomainFromActor(moderationText) getDomainFromActor(moderationText)
fullBlockDomain = getFullDomain(blockDomain, blockPort) fullBlockDomain = \
get_full_domain(blockDomain, blockPort)
if '@' in moderationText: if '@' in moderationText:
# nick@domain or *@domain # nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1] fullBlockDomain = moderationText.split('@')[1]
@ -1987,7 +1988,8 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain # https://domain
blockDomain, blockPort = \ blockDomain, blockPort = \
getDomainFromActor(moderationText) getDomainFromActor(moderationText)
fullBlockDomain = getFullDomain(blockDomain, blockPort) fullBlockDomain = \
get_full_domain(blockDomain, blockPort)
if '@' in moderationText: if '@' in moderationText:
# nick@domain or *@domain # nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1] fullBlockDomain = moderationText.split('@')[1]
@ -2368,7 +2370,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
optionsDomain, optionsPort = getDomainFromActor(optionsActor) optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = getFullDomain(optionsDomain, optionsPort) optionsDomainFull = get_full_domain(optionsDomain, optionsPort)
if chooserNickname == optionsNickname and \ if chooserNickname == optionsNickname and \
optionsDomain == domain and \ optionsDomain == domain and \
optionsPort == port: optionsPort == port:
@ -2926,7 +2928,8 @@ class PubServer(BaseHTTPRequestHandler):
followingNickname = getNicknameFromActor(followingActor) followingNickname = getNicknameFromActor(followingActor)
followingDomain, followingPort = \ followingDomain, followingPort = \
getDomainFromActor(followingActor) getDomainFromActor(followingActor)
followingDomainFull = getFullDomain(followingDomain, followingPort) followingDomainFull = \
get_full_domain(followingDomain, followingPort)
if followerNickname == followingNickname and \ if followerNickname == followingNickname and \
followingDomain == domain and \ followingDomain == domain and \
followingPort == port: followingPort == port:
@ -3123,7 +3126,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
blockingDomain, blockingPort = \ blockingDomain, blockingPort = \
getDomainFromActor(blockingActor) getDomainFromActor(blockingActor)
blockingDomainFull = getFullDomain(blockingDomain, blockingPort) blockingDomainFull = get_full_domain(blockingDomain, blockingPort)
if blockerNickname == blockingNickname and \ if blockerNickname == blockingNickname and \
blockingDomain == domain and \ blockingDomain == domain and \
blockingPort == port: blockingPort == port:
@ -3210,7 +3213,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
blockingDomain, blockingPort = \ blockingDomain, blockingPort = \
getDomainFromActor(blockingActor) getDomainFromActor(blockingActor)
blockingDomainFull = getFullDomain(blockingDomain, blockingPort) blockingDomainFull = get_full_domain(blockingDomain, blockingPort)
if blockerNickname == blockingNickname and \ if blockerNickname == blockingNickname and \
blockingDomain == domain and \ blockingDomain == domain and \
blockingPort == port: blockingPort == port:
@ -3513,7 +3516,7 @@ class PubServer(BaseHTTPRequestHandler):
searchDomain, searchPort = \ searchDomain, searchPort = \
getDomainFromActor(searchStr) getDomainFromActor(searchStr)
searchDomainFull = \ searchDomainFull = \
getFullDomain(searchDomain, searchPort) get_full_domain(searchDomain, searchPort)
actor = \ actor = \
local_actor_url(http_prefix, searchNickname, local_actor_url(http_prefix, searchNickname,
searchDomainFull) searchDomainFull)
@ -7902,7 +7905,8 @@ class PubServer(BaseHTTPRequestHandler):
handleNickname = getNicknameFromActor(followingHandle) handleNickname = getNicknameFromActor(followingHandle)
handleDomain, handlePort = getDomainFromActor(followingHandle) handleDomain, handlePort = getDomainFromActor(followingHandle)
followingHandle = \ followingHandle = \
handleNickname + '@' + getFullDomain(handleDomain, handlePort) handleNickname + '@' + \
get_full_domain(handleDomain, handlePort)
if '@' in followingHandle: if '@' in followingHandle:
if not self._establishSession("followApproveButton"): if not self._establishSession("followApproveButton"):
self._404() self._404()
@ -8060,7 +8064,8 @@ class PubServer(BaseHTTPRequestHandler):
handleNickname = getNicknameFromActor(followingHandle) handleNickname = getNicknameFromActor(followingHandle)
handleDomain, handlePort = getDomainFromActor(followingHandle) handleDomain, handlePort = getDomainFromActor(followingHandle)
followingHandle = \ followingHandle = \
handleNickname + '@' + getFullDomain(handleDomain, handlePort) handleNickname + '@' + \
get_full_domain(handleDomain, handlePort)
if '@' in followingHandle: if '@' in followingHandle:
manualDenyFollowRequestThread(self.server.session, manualDenyFollowRequestThread(self.server.session,
base_dir, http_prefix, base_dir, http_prefix,
@ -13258,11 +13263,11 @@ class PubServer(BaseHTTPRequestHandler):
if self.headers.get('referer'): if self.headers.get('referer'):
refererDomain, refererPort = \ refererDomain, refererPort = \
getDomainFromActor(self.headers['referer']) getDomainFromActor(self.headers['referer'])
refererDomain = getFullDomain(refererDomain, refererPort) refererDomain = get_full_domain(refererDomain, refererPort)
elif self.headers.get('Referer'): elif self.headers.get('Referer'):
refererDomain, refererPort = \ refererDomain, refererPort = \
getDomainFromActor(self.headers['Referer']) getDomainFromActor(self.headers['Referer'])
refererDomain = getFullDomain(refererDomain, refererPort) refererDomain = get_full_domain(refererDomain, refererPort)
elif self.headers.get('Signature'): elif self.headers.get('Signature'):
if 'keyId="' in self.headers['Signature']: if 'keyId="' in self.headers['Signature']:
refererDomain = self.headers['Signature'].split('keyId="')[1] refererDomain = self.headers['Signature'].split('keyId="')[1]
@ -18735,7 +18740,7 @@ def runDaemon(content_license_url: str,
httpd.maxPostsInBox = 32000 httpd.maxPostsInBox = 32000
httpd.domain = domain httpd.domain = domain
httpd.port = port httpd.port = port
httpd.domain_full = getFullDomain(domain, port) httpd.domain_full = get_full_domain(domain, port)
save_domain_qrcode(base_dir, http_prefix, httpd.domain_full) save_domain_qrcode(base_dir, http_prefix, httpd.domain_full)
httpd.http_prefix = http_prefix httpd.http_prefix = http_prefix
httpd.debug = debug httpd.debug = debug

View File

@ -12,7 +12,7 @@ from datetime import datetime
from utils import hasObjectString from utils import hasObjectString
from utils import removeDomainPort from utils import removeDomainPort
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -39,7 +39,7 @@ def sendDeleteViaServer(base_dir: str, session,
print('WARN: No session for sendDeleteViaServer') print('WARN: No session for sendDeleteViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'

View File

@ -18,7 +18,7 @@ from pathlib import Path
from random import randint from random import randint
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import has_object_dict from utils import has_object_dict
from utils import getFullDomain from utils import get_full_domain
from utils import isDM from utils import isDM
from utils import loadTranslationsFromFile from utils import loadTranslationsFromFile
from utils import removeHtml from utils import removeHtml
@ -806,7 +806,7 @@ def _desktopShowActor(base_dir: str, actor_json: {}, translate: {},
actor = actor_json['id'] actor = actor_json['id']
actorNickname = getNicknameFromActor(actor) actorNickname = getNicknameFromActor(actor)
actorDomain, actorPort = getDomainFromActor(actor) actorDomain, actorPort = getDomainFromActor(actor)
actorDomainFull = getFullDomain(actorDomain, actorPort) actorDomainFull = get_full_domain(actorDomain, actorPort)
handle = '@' + actorNickname + '@' + actorDomainFull handle = '@' + actorNickname + '@' + actorDomainFull
sayStr = 'Profile for ' + html.unescape(handle) sayStr = 'Profile for ' + html.unescape(handle)
@ -1284,7 +1284,7 @@ def _desktopShowFollowRequests(followRequestsJson: {}, translate: {}) -> None:
handleNickname = getNicknameFromActor(item) handleNickname = getNicknameFromActor(item)
handleDomain, handlePort = getDomainFromActor(item) handleDomain, handlePort = getDomainFromActor(item)
handleDomainFull = \ handleDomainFull = \
getFullDomain(handleDomain, handlePort) get_full_domain(handleDomain, handlePort)
print(indent + ' 👤 ' + print(indent + ' 👤 ' +
handleNickname + '@' + handleDomainFull) handleNickname + '@' + handleDomainFull)
@ -1310,7 +1310,7 @@ def _desktopShowFollowing(followingJson: {}, translate: {},
handleNickname = getNicknameFromActor(item) handleNickname = getNicknameFromActor(item)
handleDomain, handlePort = getDomainFromActor(item) handleDomain, handlePort = getDomainFromActor(item)
handleDomainFull = \ handleDomainFull = \
getFullDomain(handleDomain, handlePort) get_full_domain(handleDomain, handlePort)
print(indent + ' 👤 ' + print(indent + ' 👤 ' +
handleNickname + '@' + handleDomainFull) handleNickname + '@' + handleDomainFull)
@ -1409,7 +1409,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
_sayCommand(sayStr, sayStr, screenreader, _sayCommand(sayStr, sayStr, screenreader,
system_language, espeak) system_language, espeak)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
yourActor = local_actor_url(http_prefix, nickname, domain_full) yourActor = local_actor_url(http_prefix, nickname, domain_full)
actor_json = None actor_json = None

View File

@ -68,7 +68,7 @@ from auth import createPassword
from utils import removeDomainPort from utils import removeDomainPort
from utils import getPortFromDomain from utils import getPortFromDomain
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import setConfigParam from utils import setConfigParam
from utils import getConfigParam from utils import getConfigParam
from utils import getDomainFromActor from utils import getDomainFromActor
@ -704,7 +704,7 @@ if args.posts:
postsNickname = getNicknameFromActor(args.posts) postsNickname = getNicknameFromActor(args.posts)
postsDomain, postsPort = getDomainFromActor(args.posts) postsDomain, postsPort = getDomainFromActor(args.posts)
args.posts = \ args.posts = \
getFullDomain(postsNickname + '@' + postsDomain, postsPort) get_full_domain(postsNickname + '@' + postsDomain, postsPort)
else: else:
print('Syntax: --posts nickname@domain') print('Syntax: --posts nickname@domain')
sys.exit() sys.exit()
@ -738,7 +738,7 @@ if args.postDomains:
postsNickname = getNicknameFromActor(args.postDomains) postsNickname = getNicknameFromActor(args.postDomains)
postsDomain, postsPort = getDomainFromActor(args.postDomains) postsDomain, postsPort = getDomainFromActor(args.postDomains)
args.postDomains = \ args.postDomains = \
getFullDomain(postsNickname + '@' + postsDomain, postsPort) get_full_domain(postsNickname + '@' + postsDomain, postsPort)
else: else:
print('Syntax: --postDomains nickname@domain') print('Syntax: --postDomains nickname@domain')
sys.exit() sys.exit()
@ -790,7 +790,7 @@ if args.postDomainsBlocked:
postsDomain, postsPort = \ postsDomain, postsPort = \
getDomainFromActor(args.postDomainsBlocked) getDomainFromActor(args.postDomainsBlocked)
args.postDomainsBlocked = \ args.postDomainsBlocked = \
getFullDomain(postsNickname + '@' + postsDomain, postsPort) get_full_domain(postsNickname + '@' + postsDomain, postsPort)
else: else:
print('Syntax: --postDomainsBlocked nickname@domain') print('Syntax: --postDomainsBlocked nickname@domain')
sys.exit() sys.exit()
@ -836,7 +836,7 @@ if args.checkDomains:
postsNickname = getNicknameFromActor(args.posts) postsNickname = getNicknameFromActor(args.posts)
postsDomain, postsPort = getDomainFromActor(args.posts) postsDomain, postsPort = getDomainFromActor(args.posts)
args.checkDomains = \ args.checkDomains = \
getFullDomain(postsNickname + '@' + postsDomain, postsPort) get_full_domain(postsNickname + '@' + postsDomain, postsPort)
else: else:
print('Syntax: --checkDomains nickname@domain') print('Syntax: --checkDomains nickname@domain')
sys.exit() sys.exit()

View File

@ -13,7 +13,7 @@ from utils import hasObjectStringObject
from utils import hasObjectStringType from utils import hasObjectStringType
from utils import removeDomainPort from utils import removeDomainPort
from utils import has_users_path from utils import has_users_path
from utils import getFullDomain from utils import get_full_domain
from utils import getFollowersList from utils import getFollowersList
from utils import validNickname from utils import validNickname
from utils import domainPermitted from utils import domainPermitted
@ -184,7 +184,8 @@ def isFollowingActor(base_dir: str,
return False return False
followingDomain, followingPort = getDomainFromActor(actor) followingDomain, followingPort = getDomainFromActor(actor)
followingHandle = \ followingHandle = \
getFullDomain(followingNickname + '@' + followingDomain, followingPort) get_full_domain(followingNickname + '@' + followingDomain,
followingPort)
if followingHandle.lower() in open(followingFile).read().lower(): if followingHandle.lower() in open(followingFile).read().lower():
return True return True
return False return False
@ -464,7 +465,7 @@ def getFollowingFeed(base_dir: str, domain: str, port: int, path: str,
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
return None return None
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
if headerOnly: if headerOnly:
firstStr = \ firstStr = \
@ -632,8 +633,8 @@ def storeFollowRequest(base_dir: str,
if not os.path.isdir(accountsDir): if not os.path.isdir(accountsDir):
return False return False
domain_full = getFullDomain(domain, fromPort) domain_full = get_full_domain(domain, fromPort)
approveHandle = getFullDomain(nickname + '@' + domain, fromPort) approveHandle = get_full_domain(nickname + '@' + domain, fromPort)
if group_account: if group_account:
approveHandle = '!' + approveHandle approveHandle = '!' + approveHandle
@ -819,7 +820,7 @@ def followedAccountRejects(session, base_dir: str, http_prefix: str,
' port ' + str(port) + ' to ' + ' port ' + str(port) + ' to ' +
nickname + '@' + domain + ' port ' + str(fromPort)) nickname + '@' + domain + ' port ' + str(fromPort))
client_to_server = False client_to_server = False
denyHandle = getFullDomain(nickname + '@' + domain, fromPort) denyHandle = get_full_domain(nickname + '@' + domain, fromPort)
group_account = False group_account = False
if hasGroupType(base_dir, personUrl, person_cache): if hasGroupType(base_dir, personUrl, person_cache):
group_account = True group_account = True
@ -862,10 +863,10 @@ def sendFollowRequest(session, base_dir: str,
print('You are not permitted to follow the domain ' + followDomain) print('You are not permitted to follow the domain ' + followDomain)
return None return None
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
followActor = local_actor_url(http_prefix, nickname, fullDomain) followActor = local_actor_url(http_prefix, nickname, fullDomain)
requestDomain = getFullDomain(followDomain, followPort) requestDomain = get_full_domain(followDomain, followPort)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -952,9 +953,9 @@ def sendFollowRequestViaServer(base_dir: str, session,
print('WARN: No session for sendFollowRequestViaServer') print('WARN: No session for sendFollowRequestViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
followDomainFull = getFullDomain(followDomain, followPort) followDomainFull = get_full_domain(followDomain, followPort)
followActor = local_actor_url(http_prefix, fromNickname, fromDomainFull) followActor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
followedId = \ followedId = \
@ -1042,8 +1043,8 @@ def sendUnfollowRequestViaServer(base_dir: str, session,
print('WARN: No session for sendUnfollowRequestViaServer') print('WARN: No session for sendUnfollowRequestViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
followDomainFull = getFullDomain(followDomain, followPort) followDomainFull = get_full_domain(followDomain, followPort)
followActor = local_actor_url(http_prefix, fromNickname, fromDomainFull) followActor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
followedId = \ followedId = \
@ -1137,7 +1138,7 @@ def getFollowingViaServer(base_dir: str, session,
print('WARN: No session for getFollowingViaServer') print('WARN: No session for getFollowingViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
followActor = local_actor_url(http_prefix, nickname, domain_full) followActor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1178,7 +1179,7 @@ def getFollowersViaServer(base_dir: str, session,
print('WARN: No session for getFollowersViaServer') print('WARN: No session for getFollowersViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
followActor = local_actor_url(http_prefix, nickname, domain_full) followActor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1219,7 +1220,7 @@ def getFollowRequestsViaServer(base_dir: str, session,
print('WARN: No session for getFollowRequestsViaServer') print('WARN: No session for getFollowRequestsViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
followActor = local_actor_url(http_prefix, nickname, domain_full) followActor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1262,7 +1263,7 @@ def approveFollowRequestViaServer(base_dir: str, session,
print('WARN: No session for approveFollowRequestViaServer') print('WARN: No session for approveFollowRequestViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1303,7 +1304,7 @@ def denyFollowRequestViaServer(base_dir: str, session,
print('WARN: No session for denyFollowRequestViaServer') print('WARN: No session for denyFollowRequestViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1403,7 +1404,7 @@ def outboxUndoFollow(base_dir: str, message_json: {}, debug: bool) -> None:
return return
domainFollower, portFollower = \ domainFollower, portFollower = \
getDomainFromActor(message_json['object']['actor']) getDomainFromActor(message_json['object']['actor'])
domainFollowerFull = getFullDomain(domainFollower, portFollower) domainFollowerFull = get_full_domain(domainFollower, portFollower)
nicknameFollowing = getNicknameFromActor(message_json['object']['object']) nicknameFollowing = getNicknameFromActor(message_json['object']['object'])
if not nicknameFollowing: if not nicknameFollowing:
@ -1412,7 +1413,7 @@ def outboxUndoFollow(base_dir: str, message_json: {}, debug: bool) -> None:
return return
domainFollowing, portFollowing = \ domainFollowing, portFollowing = \
getDomainFromActor(message_json['object']['object']) getDomainFromActor(message_json['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing) domainFollowingFull = get_full_domain(domainFollowing, portFollowing)
group_account = \ group_account = \
hasGroupType(base_dir, message_json['object']['object'], None) hasGroupType(base_dir, message_json['object']['object'], None)

View File

@ -22,7 +22,7 @@ from cryptography.hazmat.primitives.asymmetric import utils as hazutils
import base64 import base64
from time import gmtime, strftime from time import gmtime, strftime
import datetime import datetime
from utils import getFullDomain from utils import get_full_domain
from utils import get_sha_256 from utils import get_sha_256
from utils import get_sha_512 from utils import get_sha_512
from utils import local_actor_url from utils import local_actor_url
@ -76,9 +76,9 @@ def signPostHeaders(dateStr: str, privateKeyPem: str,
"""Returns a raw signature string that can be plugged into a header and """Returns a raw signature string that can be plugged into a header and
used to verify the authenticity of an HTTP transmission. used to verify the authenticity of an HTTP transmission.
""" """
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
toDomain = getFullDomain(toDomain, toPort) toDomain = get_full_domain(toDomain, toPort)
if not dateStr: if not dateStr:
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
@ -156,9 +156,9 @@ def signPostHeadersNew(dateStr: str, privateKeyPem: str,
used to verify the authenticity of an HTTP transmission. used to verify the authenticity of an HTTP transmission.
See https://tools.ietf.org/html/draft-ietf-httpbis-message-signatures See https://tools.ietf.org/html/draft-ietf-httpbis-message-signatures
""" """
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
toDomain = getFullDomain(toDomain, toPort) toDomain = get_full_domain(toDomain, toPort)
timeFormat = "%a, %d %b %Y %H:%M:%S %Z" timeFormat = "%a, %d %b %Y %H:%M:%S %Z"
if not dateStr: if not dateStr:
@ -247,7 +247,7 @@ def createSignedHeader(dateStr: str, privateKeyPem: str, nickname: str,
""" """
algorithm = 'rsa-sha256' algorithm = 'rsa-sha256'
digestAlgorithm = 'rsa-sha256' digestAlgorithm = 'rsa-sha256'
headerDomain = getFullDomain(toDomain, toPort) headerDomain = get_full_domain(toDomain, toPort)
# if no date is given then create one # if no date is given then create one
if not dateStr: if not dateStr:

View File

@ -38,7 +38,7 @@ from utils import isRecentPost
from utils import getConfigParam from utils import getConfigParam
from utils import has_users_path from utils import has_users_path
from utils import valid_post_date from utils import valid_post_date
from utils import getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import isBlogPost from utils import isBlogPost
@ -491,7 +491,7 @@ def savePostToInboxQueue(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: post from ' + postNickname + ' blocked') print('DEBUG: post from ' + postNickname + ' blocked')
return None return None
postDomain = getFullDomain(postDomain, postPort) postDomain = get_full_domain(postDomain, postPort)
if has_object_dict(post_json_object): if has_object_dict(post_json_object):
if post_json_object['object'].get('inReplyTo'): if post_json_object['object'].get('inReplyTo'):
@ -646,7 +646,7 @@ def _inboxPostRecipients(base_dir: str, post_json_object: {},
domain = removeDomainPort(domain) domain = removeDomainPort(domain)
domainBase = domain domainBase = domain
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
domainMatch = '/' + domain + '/users/' domainMatch = '/' + domain + '/users/'
actor = post_json_object['actor'] actor = post_json_object['actor']
@ -764,7 +764,7 @@ def _receiveUndoFollow(session, base_dir: str, http_prefix: str,
return False return False
domainFollower, portFollower = \ domainFollower, portFollower = \
getDomainFromActor(message_json['object']['actor']) getDomainFromActor(message_json['object']['actor'])
domainFollowerFull = getFullDomain(domainFollower, portFollower) domainFollowerFull = get_full_domain(domainFollower, portFollower)
nicknameFollowing = \ nicknameFollowing = \
getNicknameFromActor(message_json['object']['object']) getNicknameFromActor(message_json['object']['object'])
@ -774,7 +774,7 @@ def _receiveUndoFollow(session, base_dir: str, http_prefix: str,
return False return False
domainFollowing, portFollowing = \ domainFollowing, portFollowing = \
getDomainFromActor(message_json['object']['object']) getDomainFromActor(message_json['object']['object'])
domainFollowingFull = getFullDomain(domainFollowing, portFollowing) domainFollowingFull = get_full_domain(domainFollowing, portFollowing)
group_account = \ group_account = \
hasGroupType(base_dir, message_json['object']['actor'], None) hasGroupType(base_dir, message_json['object']['actor'], None)
@ -834,8 +834,8 @@ def _personReceiveUpdate(base_dir: str,
if debug: if debug:
print('Receiving actor update for ' + personJson['url'] + print('Receiving actor update for ' + personJson['url'] +
' ' + str(personJson)) ' ' + str(personJson))
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
updateDomainFull = getFullDomain(updateDomain, updatePort) updateDomainFull = get_full_domain(updateDomain, updatePort)
usersPaths = get_user_paths() usersPaths = get_user_paths()
usersStrFound = False usersStrFound = False
for usersStr in usersPaths: for usersStr in usersPaths:
@ -1536,7 +1536,7 @@ def _receiveBookmark(recentPostsCache: {},
if debug: if debug:
print('DEBUG: inbox bookmark Add target is not string') print('DEBUG: inbox bookmark Add target is not string')
return False return False
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
if debug: if debug:
@ -1648,7 +1648,7 @@ def _receiveUndoBookmark(recentPostsCache: {},
if debug: if debug:
print('DEBUG: inbox Remove bookmark target is not string') print('DEBUG: inbox Remove bookmark target is not string')
return False return False
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if not message_json['actor'].endswith(domain_full + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
if debug: if debug:
@ -1741,7 +1741,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
print('DEBUG: Delete activity arrived') print('DEBUG: Delete activity arrived')
if not hasObjectString(message_json, debug): if not hasObjectString(message_json, debug):
return False return False
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
deletePrefix = http_prefix + '://' + domain_full + '/' deletePrefix = http_prefix + '://' + domain_full + '/'
if (not allow_deletion and if (not allow_deletion and
(not message_json['object'].startswith(deletePrefix) or (not message_json['object'].startswith(deletePrefix) or
@ -1899,7 +1899,7 @@ def _receiveAnnounce(recentPostsCache: {},
if debug: if debug:
print('DEBUG: Downloading announce post ' + message_json['actor'] + print('DEBUG: Downloading announce post ' + message_json['actor'] +
' -> ' + message_json['object']) ' -> ' + message_json['object'])
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# Generate html. This also downloads the announced post. # Generate html. This also downloads the announced post.
pageNumber = 1 pageNumber = 1
@ -1990,7 +1990,7 @@ def _receiveAnnounce(recentPostsCache: {},
if isRecentPost(post_json_object, 3): if isRecentPost(post_json_object, 3):
if not os.path.isfile(postFilename + '.tts'): if not os.path.isfile(postFilename + '.tts'):
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
updateSpeaker(base_dir, http_prefix, updateSpeaker(base_dir, http_prefix,
nickname, domain, domain_full, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
@ -2650,7 +2650,7 @@ def _sendToGroupMembers(session, base_dir: str, handle: str, port: int,
return return
nickname = handle.split('@')[0].replace('!', '') nickname = handle.split('@')[0].replace('!', '')
domain = handle.split('@')[1] domain = handle.split('@')[1]
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
groupActor = local_actor_url(http_prefix, nickname, domain_full) groupActor = local_actor_url(http_prefix, nickname, domain_full)
if groupActor not in post_json_object['to']: if groupActor not in post_json_object['to']:
return return
@ -3142,11 +3142,11 @@ def _lowFrequencyPostNotification(base_dir: str, http_prefix: str,
return return
fromNickname = getNicknameFromActor(attributedTo) fromNickname = getNicknameFromActor(attributedTo)
fromDomain, fromPort = getDomainFromActor(attributedTo) fromDomain, fromPort = getDomainFromActor(attributedTo)
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
if notifyWhenPersonPosts(base_dir, nickname, domain, if notifyWhenPersonPosts(base_dir, nickname, domain,
fromNickname, fromDomainFull): fromNickname, fromDomainFull):
postId = removeIdEnding(jsonObj['id']) postId = removeIdEnding(jsonObj['id'])
domFull = getFullDomain(domain, port) domFull = get_full_domain(domain, port)
postLink = \ postLink = \
local_actor_url(http_prefix, nickname, domFull) + \ local_actor_url(http_prefix, nickname, domFull) + \
'?notifypost=' + postId.replace('/', '-') '?notifypost=' + postId.replace('/', '-')
@ -3170,7 +3170,7 @@ def _checkForGitPatches(base_dir: str, nickname: str, domain: str,
return 0 return 0
fromNickname = getNicknameFromActor(attributedTo) fromNickname = getNicknameFromActor(attributedTo)
fromDomain, fromPort = getDomainFromActor(attributedTo) fromDomain, fromPort = getDomainFromActor(attributedTo)
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
if receiveGitPatch(base_dir, nickname, domain, if receiveGitPatch(base_dir, nickname, domain,
jsonObj['type'], jsonObj['summary'], jsonObj['type'], jsonObj['summary'],
jsonObj['content'], jsonObj['content'],
@ -3422,7 +3422,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
jsonObj = None jsonObj = None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if _validPostContent(base_dir, nickname, domain, if _validPostContent(base_dir, nickname, domain,
post_json_object, max_mentions, max_emoji, post_json_object, max_mentions, max_emoji,
allow_local_network_access, debug, allow_local_network_access, debug,
@ -3550,7 +3550,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
else: else:
if boxname == 'inbox': if boxname == 'inbox':
if isRecentPost(post_json_object, 3): if isRecentPost(post_json_object, 3):
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
updateSpeaker(base_dir, http_prefix, updateSpeaker(base_dir, http_prefix,
nickname, domain, domain_full, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
@ -3874,7 +3874,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
return False return False
domain, tempPort = getDomainFromActor(message_json['actor']) domain, tempPort = getDomainFromActor(message_json['actor'])
fromPort = port fromPort = port
domain_full = getFullDomain(domain, tempPort) domain_full = get_full_domain(domain, tempPort)
if tempPort: if tempPort:
fromPort = tempPort fromPort = tempPort
if not domainPermitted(domain, federation_list): if not domainPermitted(domain, federation_list):
@ -3900,7 +3900,7 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: follow domain not permitted ' + domainToFollow) print('DEBUG: follow domain not permitted ' + domainToFollow)
return True return True
domainToFollowFull = getFullDomain(domainToFollow, tempPort) domainToFollowFull = get_full_domain(domainToFollow, tempPort)
nicknameToFollow = getNicknameFromActor(message_json['object']) nicknameToFollow = getNicknameFromActor(message_json['object'])
if not nicknameToFollow: if not nicknameToFollow:
if debug: if debug:

10
like.py
View File

@ -15,7 +15,7 @@ from utils import hasObjectStringType
from utils import removeDomainPort from utils import removeDomainPort
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 getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -86,7 +86,7 @@ def _like(recentPostsCache: {},
if not urlPermitted(objectUrl, federation_list): if not urlPermitted(objectUrl, federation_list):
return None return None
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
newLikeJson = { newLikeJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -156,7 +156,7 @@ def likePost(recentPostsCache: {},
signing_priv_key_pem: str) -> {}: signing_priv_key_pem: str) -> {}:
"""Likes a given status post. This is only used by unit tests """Likes a given status post. This is only used by unit tests
""" """
likeDomain = getFullDomain(likeDomain, likePort) likeDomain = get_full_domain(likeDomain, likePort)
actorLiked = local_actor_url(http_prefix, likeNickname, likeDomain) actorLiked = local_actor_url(http_prefix, likeNickname, likeDomain)
objectUrl = actorLiked + '/statuses/' + str(likeStatusNumber) objectUrl = actorLiked + '/statuses/' + str(likeStatusNumber)
@ -181,7 +181,7 @@ def sendLikeViaServer(base_dir: str, session,
print('WARN: No session for sendLikeViaServer') print('WARN: No session for sendLikeViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
@ -264,7 +264,7 @@ def sendUndoLikeViaServer(base_dir: str, session,
print('WARN: No session for sendUndoLikeViaServer') print('WARN: No session for sendUndoLikeViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)

View File

@ -16,7 +16,7 @@ from random import randint
from hashlib import sha1 from hashlib import sha1
from auth import createPassword from auth import createPassword
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import getFullDomain from utils import get_full_domain
from utils import getImageExtensions from utils import getImageExtensions
from utils import getVideoExtensions from utils import getVideoExtensions
from utils import getAudioExtensions from utils import getAudioExtensions
@ -324,7 +324,7 @@ def attachMedia(base_dir: str, http_prefix: str,
if mediaType == 'audio/mpeg': if mediaType == 'audio/mpeg':
fileExtension = 'mp3' fileExtension = 'mp3'
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
mPath = getMediaPath() mPath = getMediaPath()
mediaPath = mPath + '/' + createPassword(32) + '.' + fileExtension mediaPath = mPath + '/' + createPassword(32) + '.' + fileExtension

View File

@ -27,7 +27,7 @@ from posts import archivePostsForPerson
from content import validHashTag from content import validHashTag
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import removeHtml from utils import removeHtml
from utils import getFullDomain from utils import get_full_domain
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getStatusNumber from utils import getStatusNumber
@ -394,7 +394,7 @@ def _newswireHashtagProcessing(session, base_dir: str, post_json_object: {},
with open(rulesFilename, 'r') as f: with open(rulesFilename, 'r') as f:
rules = f.readlines() rules = f.readlines()
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# get the full text content of the post # get the full text content of the post
content = '' content = ''
@ -672,7 +672,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str,
blog['object']['content'] = rssDescription blog['object']['content'] = rssDescription
blog['object']['contentMap'][system_language] = rssDescription blog['object']['contentMap'][system_language] = rssDescription
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
hashtags = item[6] hashtags = item[6]

View File

@ -20,7 +20,7 @@ from utils import hasObjectStringType
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import has_object_dict from utils import has_object_dict
from utils import getLocalNetworkAddresses from utils import getLocalNetworkAddresses
from utils import getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import dangerousMarkup from utils import dangerousMarkup
@ -100,7 +100,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
if debug: if debug:
print('DEBUG: c2s actor update id is not a string') print('DEBUG: c2s actor update id is not a string')
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
if len(message_json['to']) != 1: if len(message_json['to']) != 1:
if debug: if debug:
@ -280,7 +280,7 @@ def postMessageToOutbox(session, translate: {},
return False return False
testDomain, testPort = getDomainFromActor(message_json['actor']) testDomain, testPort = getDomainFromActor(message_json['actor'])
testDomain = getFullDomain(testDomain, testPort) testDomain = get_full_domain(testDomain, testPort)
if isBlockedDomain(base_dir, testDomain): if isBlockedDomain(base_dir, testDomain):
if debug: if debug:
print('DEBUG: domain is blocked: ' + message_json['actor']) print('DEBUG: domain is blocked: ' + message_json['actor'])

View File

@ -44,7 +44,7 @@ from utils import replaceUsersWithAt
from utils import removeLineEndings from utils import removeLineEndings
from utils import removeDomainPort from utils import removeDomainPort
from utils import getStatusNumber from utils import getStatusNumber
from utils import getFullDomain from utils import get_full_domain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
@ -108,7 +108,7 @@ def setProfileImage(base_dir: str, http_prefix: str,
imageFilename = imageFilename.replace('~/', str(Path.home()) + '/') imageFilename = imageFilename.replace('~/', str(Path.home()) + '/')
domain = removeDomainPort(domain) domain = removeDomainPort(domain)
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
personFilename = base_dir + '/accounts/' + handle + '.json' personFilename = base_dir + '/accounts/' + handle + '.json'
@ -366,7 +366,7 @@ def _createPersonBase(base_dir: str, nickname: str, domain: str, port: int,
handle = nickname + '@' + domain handle = nickname + '@' + domain
originalDomain = domain originalDomain = domain
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
personType = 'Person' personType = 'Person'
if group_account: if group_account:
@ -586,7 +586,7 @@ def savePersonQrcode(base_dir: str,
qrcodeFilename = acct_dir(base_dir, nickname, domain) + '/qrcode.png' qrcodeFilename = acct_dir(base_dir, nickname, domain) + '/qrcode.png'
if os.path.isfile(qrcodeFilename): if os.path.isfile(qrcodeFilename):
return return
handle = getFullDomain('@' + nickname + '@' + domain, port) handle = get_full_domain('@' + nickname + '@' + domain, port)
url = pyqrcode.create(handle) url = pyqrcode.create(handle)
url.png(qrcodeFilename, scale) url.png(qrcodeFilename, scale)
@ -1115,7 +1115,7 @@ def canRemovePost(base_dir: str, nickname: str,
if '/statuses/' not in postId: if '/statuses/' not in postId:
return False return False
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# is the post by the admin? # is the post by the admin?
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
@ -1141,7 +1141,7 @@ def _removeTagsForNickname(base_dir: str, nickname: str,
""" """
if not os.path.isdir(base_dir + '/tags'): if not os.path.isdir(base_dir + '/tags'):
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
matchStr = domain_full + '/users/' + nickname + '/' matchStr = domain_full + '/users/' + nickname + '/'
directory = os.fsencode(base_dir + '/tags/') directory = os.fsencode(base_dir + '/tags/')
for f in os.scandir(directory): for f in os.scandir(directory):

4
pgp.py
View File

@ -13,7 +13,7 @@ from pathlib import Path
from person import getActorJson from person import getActorJson
from utils import containsPGPPublicKey from utils import containsPGPPublicKey
from utils import isPGPEncrypted from utils import isPGPEncrypted
from utils import getFullDomain from utils import get_full_domain
from utils import getStatusNumber from utils import getStatusNumber
from utils import local_actor_url from utils import local_actor_url
from utils import replaceUsersWithAt from utils import replaceUsersWithAt
@ -480,7 +480,7 @@ def pgpPublicKeyUpload(base_dir: str, session,
PGPpubKey = test PGPpubKey = test
PGPpubKeyId = None PGPpubKeyId = None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if debug: if debug:
print('PGP test domain: ' + domain_full) print('PGP test domain: ' + domain_full)

View File

@ -48,7 +48,7 @@ from utils import fileLastModified
from utils import isPublicPost from utils import isPublicPost
from utils import has_users_path from utils import has_users_path
from utils import valid_post_date from utils import valid_post_date
from utils import getFullDomain from utils import get_full_domain
from utils import getFollowersList from utils import getFollowersList
from utils import isEvil from utils import isEvil
from utils import getStatusNumber from utils import getStatusNumber
@ -1151,7 +1151,7 @@ def _createPostC2S(base_dir: str, nickname: str, domain: str, port: int,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Creates a new client-to-server post """Creates a new client-to-server post
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
idStr = \ idStr = \
local_actor_url(http_prefix, nickname, domain_full) + \ local_actor_url(http_prefix, nickname, domain_full) + \
'/statuses/' + statusNumber + '/replies' '/statuses/' + statusNumber + '/replies'
@ -1398,7 +1398,7 @@ def _createPostBase(base_dir: str,
tags = [] tags = []
hashtagsDict = {} hashtagsDict = {}
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
# add tags # add tags
if nickname != 'news': if nickname != 'news':
@ -1569,7 +1569,7 @@ def outboxMessageCreateWrap(http_prefix: str,
https://www.w3.org/TR/activitypub/#object-without-create https://www.w3.org/TR/activitypub/#object-without-create
""" """
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
if message_json.get('published'): if message_json.get('published'):
published = message_json['published'] published = message_json['published']
@ -1604,7 +1604,7 @@ def _postIsAddressedToFollowers(base_dir: str,
post_json_object: {}) -> bool: post_json_object: {}) -> bool:
"""Returns true if the given post is addressed to followers of the nickname """Returns true if the given post is addressed to followers of the nickname
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if not post_json_object.get('object'): if not post_json_object.get('object'):
return False return False
@ -1771,7 +1771,7 @@ def createPublicPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Public post """Public post
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
isModerationReport = False isModerationReport = False
eventUUID = None eventUUID = None
category = None category = None
@ -1907,7 +1907,7 @@ def createQuestionPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Question post with multiple choice options """Question post with multiple choice options
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
localActor = local_actor_url(http_prefix, nickname, domain_full) localActor = local_actor_url(http_prefix, nickname, domain_full)
message_json = \ message_json = \
_createPostBase(base_dir, nickname, domain, port, _createPostBase(base_dir, nickname, domain, port,
@ -1957,7 +1957,7 @@ def createUnlistedPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
localActor = local_actor_url(http_prefix, nickname, domain_full) localActor = local_actor_url(http_prefix, nickname, domain_full)
return _createPostBase(base_dir, nickname, domain, port, return _createPostBase(base_dir, nickname, domain, port,
localActor + '/followers', localActor + '/followers',
@ -1992,7 +1992,7 @@ def createFollowersOnlyPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Followers only post """Followers only post
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
localActor = local_actor_url(http_prefix, nickname, domain_full) localActor = local_actor_url(http_prefix, nickname, domain_full)
return _createPostBase(base_dir, nickname, domain, port, return _createPostBase(base_dir, nickname, domain, port,
localActor + '/followers', localActor + '/followers',
@ -2110,7 +2110,7 @@ def createReportPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Send a report to moderators """Send a report to moderators
""" """
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# add a title to distinguish moderation reports from other posts # add a title to distinguish moderation reports from other posts
reportTitle = 'Moderation Report' reportTitle = 'Moderation Report'
@ -2290,7 +2290,7 @@ def sendPost(signing_priv_key_pem: str, project_version: str,
# shared inbox actor on @domain@domain # shared inbox actor on @domain@domain
toNickname = toDomain toNickname = toDomain
toDomain = getFullDomain(toDomain, toPort) toDomain = get_full_domain(toDomain, toPort)
handle = http_prefix + '://' + toDomain + '/@' + toNickname handle = http_prefix + '://' + toDomain + '/@' + toNickname
@ -2380,7 +2380,7 @@ def sendPost(signing_priv_key_pem: str, project_version: str,
# federation list then send the token for this domain # federation list then send the token for this domain
# so that it can request a catalog # so that it can request a catalog
if toDomain in shared_items_federated_domains: if toDomain in shared_items_federated_domains:
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if sharedItemFederationTokens.get(domain_full): if sharedItemFederationTokens.get(domain_full):
signatureHeaderJson['Origin'] = domain_full signatureHeaderJson['Origin'] = domain_full
signatureHeaderJson['SharesCatalog'] = \ signatureHeaderJson['SharesCatalog'] = \
@ -2439,7 +2439,7 @@ def sendPostViaServer(signing_priv_key_pem: str, project_version: str,
print('WARN: No session for sendPostViaServer') print('WARN: No session for sendPostViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname handle = http_prefix + '://' + fromDomainFull + '/@' + fromNickname
@ -2497,7 +2497,7 @@ def sendPostViaServer(signing_priv_key_pem: str, project_version: str,
local_actor_url(http_prefix, fromNickname, fromDomainFull) + \ local_actor_url(http_prefix, fromNickname, fromDomainFull) + \
'/followers' '/followers'
else: else:
toDomainFull = getFullDomain(toDomain, toPort) toDomainFull = get_full_domain(toDomain, toPort)
toPersonId = local_actor_url(http_prefix, toNickname, toDomainFull) toPersonId = local_actor_url(http_prefix, toNickname, toDomainFull)
post_json_object = \ post_json_object = \
@ -2636,7 +2636,7 @@ def sendSignedJson(post_json_object: {}, session, base_dir: str,
# shared inbox actor on @domain@domain # shared inbox actor on @domain@domain
toNickname = toDomain toNickname = toDomain
toDomain = getFullDomain(toDomain, toPort) toDomain = get_full_domain(toDomain, toPort)
toDomainUrl = http_prefix + '://' + toDomain toDomainUrl = http_prefix + '://' + toDomain
if not siteIsActive(toDomainUrl, 10): if not siteIsActive(toDomainUrl, 10):
@ -2752,7 +2752,7 @@ def sendSignedJson(post_json_object: {}, session, base_dir: str,
# optionally add a token so that the receiving instance may access # optionally add a token so that the receiving instance may access
# your shared items catalog # your shared items catalog
if sharedItemsToken: if sharedItemsToken:
signatureHeaderJson['Origin'] = getFullDomain(domain, port) signatureHeaderJson['Origin'] = get_full_domain(domain, port)
signatureHeaderJson['SharesCatalog'] = sharedItemsToken signatureHeaderJson['SharesCatalog'] = sharedItemsToken
elif debug: elif debug:
print('Not sending shared items federation token') print('Not sending shared items federation token')
@ -2960,8 +2960,8 @@ def _sendToNamedAddresses(session, base_dir: str,
continue continue
# Don't send profile/actor updates to yourself # Don't send profile/actor updates to yourself
if isProfileUpdate: if isProfileUpdate:
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
toDomainFull = getFullDomain(toDomain, toPort) toDomainFull = get_full_domain(toDomain, toPort)
if nickname == toNickname and \ if nickname == toNickname and \
domain_full == toDomainFull: domain_full == toDomainFull:
if debug: if debug:
@ -2969,8 +2969,8 @@ def _sendToNamedAddresses(session, base_dir: str,
nickname + '@' + domain_full) nickname + '@' + domain_full)
continue continue
if debug: if debug:
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
toDomainFull = getFullDomain(toDomain, toPort) toDomainFull = get_full_domain(toDomain, toPort)
print('DEBUG: Post sending s2s: ' + nickname + '@' + domain_full + print('DEBUG: Post sending s2s: ' + nickname + '@' + domain_full +
' to ' + toNickname + '@' + toDomainFull) ' to ' + toNickname + '@' + toDomainFull)
@ -2978,7 +2978,7 @@ def _sendToNamedAddresses(session, base_dir: str,
# another onion domain then switch the clearnet # another onion domain then switch the clearnet
# domain for the onion one # domain for the onion one
fromDomain = domain fromDomain = domain
fromDomainFull = getFullDomain(domain, port) fromDomainFull = get_full_domain(domain, port)
fromHttpPrefix = http_prefix fromHttpPrefix = http_prefix
if onion_domain: if onion_domain:
if toDomain.endswith('.onion'): if toDomain.endswith('.onion'):
@ -3144,7 +3144,7 @@ def sendToFollowers(session, base_dir: str,
# so that it can request a catalog # so that it can request a catalog
sharedItemsToken = None sharedItemsToken = None
if followerDomain in shared_items_federated_domains: if followerDomain in shared_items_federated_domains:
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
if sharedItemFederationTokens.get(domain_full): if sharedItemFederationTokens.get(domain_full):
sharedItemsToken = sharedItemFederationTokens[domain_full] sharedItemsToken = sharedItemFederationTokens[domain_full]
@ -3396,7 +3396,7 @@ def createModeration(base_dir: str, nickname: str, domain: str, port: int,
boxDir = createPersonDir(nickname, domain, base_dir, 'inbox') boxDir = createPersonDir(nickname, domain, base_dir, 'inbox')
boxname = 'moderation' boxname = 'moderation'
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
if not pageNumber: if not pageNumber:
pageNumber = 1 pageNumber = 1
@ -3688,7 +3688,7 @@ def _createBoxIndexed(recentPostsCache: {},
timelineNickname = 'news' timelineNickname = 'news'
originalDomain = domain originalDomain = domain
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
boxActor = local_actor_url(http_prefix, nickname, domain) boxActor = local_actor_url(http_prefix, nickname, domain)
@ -4088,7 +4088,7 @@ def getPublicPostsOfPerson(base_dir: str, nickname: str, domain: str,
if nickname.startswith('!'): if nickname.startswith('!'):
nickname = nickname[1:] nickname = nickname[1:]
group_account = True group_account = True
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
handle = http_prefix + "://" + domain_full + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
@ -4146,7 +4146,7 @@ def getPublicPostDomains(session, base_dir: str, nickname: str, domain: str,
cached_webfingers = {} cached_webfingers = {}
federation_list = [] federation_list = []
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
handle = http_prefix + "://" + domain_full + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers, webfingerHandle(session, handle, http_prefix, cached_webfingers,
@ -4242,7 +4242,7 @@ def getPublicPostInfo(session, base_dir: str, nickname: str, domain: str,
cached_webfingers = {} cached_webfingers = {}
federation_list = [] federation_list = []
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
handle = http_prefix + "://" + domain_full + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers, webfingerHandle(session, handle, http_prefix, cached_webfingers,
@ -4725,7 +4725,8 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
attributedDomain, attributedPort = \ attributedDomain, attributedPort = \
getDomainFromActor(announcedJson['object']['id']) getDomainFromActor(announcedJson['object']['id'])
if attributedNickname and attributedDomain: if attributedNickname and attributedDomain:
attributedDomain = getFullDomain(attributedDomain, attributedPort) attributedDomain = \
get_full_domain(attributedDomain, attributedPort)
if isBlocked(base_dir, nickname, domain, if isBlocked(base_dir, nickname, domain,
attributedNickname, attributedDomain): attributedNickname, attributedDomain):
_rejectAnnounce(announceFilename, _rejectAnnounce(announceFilename,
@ -4772,7 +4773,7 @@ def sendBlockViaServer(base_dir: str, session,
print('WARN: No session for sendBlockViaServer') print('WARN: No session for sendBlockViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
blockActor = local_actor_url(http_prefix, fromNickname, fromDomainFull) blockActor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -4856,7 +4857,7 @@ def sendMuteViaServer(base_dir: str, session,
print('WARN: No session for sendMuteViaServer') print('WARN: No session for sendMuteViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
handle = replaceUsersWithAt(actor) handle = replaceUsersWithAt(actor)
@ -4936,7 +4937,7 @@ def sendUndoMuteViaServer(base_dir: str, session,
print('WARN: No session for sendUndoMuteViaServer') print('WARN: No session for sendUndoMuteViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
handle = replaceUsersWithAt(actor) handle = replaceUsersWithAt(actor)
@ -5022,7 +5023,7 @@ def sendUndoBlockViaServer(base_dir: str, session,
print('WARN: No session for sendBlockViaServer') print('WARN: No session for sendBlockViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
blockActor = local_actor_url(http_prefix, fromNickname, fromDomainFull) blockActor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -5139,7 +5140,7 @@ def c2sBoxJson(base_dir: str, session,
print('WARN: No session for c2sBoxJson') print('WARN: No session for c2sBoxJson')
return None return None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)

View File

@ -17,7 +17,7 @@ from utils import hasObjectStringType
from utils import removeDomainPort from utils import removeDomainPort
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 getFullDomain from utils import get_full_domain
from utils import removeIdEnding from utils import removeIdEnding
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -82,7 +82,7 @@ def _reaction(recentPostsCache: {},
print('_reaction: Invalid emoji reaction: "' + emojiContent + '"') print('_reaction: Invalid emoji reaction: "' + emojiContent + '"')
return return
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
newReactionJson = { newReactionJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -158,7 +158,7 @@ def reactionPost(recentPostsCache: {},
signing_priv_key_pem: str) -> {}: signing_priv_key_pem: str) -> {}:
"""Adds a reaction to a given status post. This is only used by unit tests """Adds a reaction to a given status post. This is only used by unit tests
""" """
reactionDomain = getFullDomain(reactionDomain, reactionPort) reactionDomain = get_full_domain(reactionDomain, reactionPort)
actorReaction = \ actorReaction = \
local_actor_url(http_prefix, reactionNickname, reactionDomain) local_actor_url(http_prefix, reactionNickname, reactionDomain)
@ -191,7 +191,7 @@ def sendReactionViaServer(base_dir: str, session,
emojiContent + '"') emojiContent + '"')
return 7 return 7
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
@ -277,7 +277,7 @@ def sendUndoReactionViaServer(base_dir: str, session,
print('WARN: No session for sendUndoReactionViaServer') print('WARN: No session for sendUndoReactionViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)

View File

@ -26,7 +26,7 @@ from utils import hasObjectStringType
from utils import dateStringToSeconds from utils import dateStringToSeconds
from utils import dateSecondsToString from utils import dateSecondsToString
from utils import getConfigParam from utils import getConfigParam
from utils import getFullDomain from utils import get_full_domain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
@ -326,7 +326,7 @@ def addShare(base_dir: str,
published = int(time.time()) published = int(time.time())
durationSec = _addShareDurationSec(duration, published) durationSec = _addShareDurationSec(duration, published)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
itemID = _getValidSharedItemID(actor, displayName) itemID = _getValidSharedItemID(actor, displayName)
dfcId = _getshareDfcId(base_dir, system_language, dfcId = _getshareDfcId(base_dir, system_language,
@ -345,7 +345,7 @@ def addShare(base_dir: str,
imageFilename = sharesImageFilename + '.' + ext imageFilename = sharesImageFilename + '.' + ext
moveImage = True moveImage = True
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# copy or move the image for the shared item to its destination # copy or move the image for the shared item to its destination
if imageFilename: if imageFilename:
@ -486,7 +486,7 @@ def getSharesFeedForPerson(base_dir: str,
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
return None return None
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
handleDomain = removeDomainPort(domain) handleDomain = removeDomainPort(domain)
sharesFilename = \ sharesFilename = \
@ -576,7 +576,7 @@ def sendShareViaServer(base_dir, session,
if newItemCurrency != itemCurrency: if newItemCurrency != itemCurrency:
itemCurrency = newItemCurrency itemCurrency = newItemCurrency
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -689,7 +689,7 @@ def sendUndoShareViaServer(base_dir: str, session,
print('WARN: No session for sendUndoShareViaServer') print('WARN: No session for sendUndoShareViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -796,7 +796,7 @@ def sendWantedViaServer(base_dir, session,
if newItemCurrency != itemCurrency: if newItemCurrency != itemCurrency:
itemCurrency = newItemCurrency itemCurrency = newItemCurrency
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -909,7 +909,7 @@ def sendUndoWantedViaServer(base_dir: str, session,
print('WARN: No session for sendUndoWantedViaServer') print('WARN: No session for sendUndoWantedViaServer')
return 6 return 6
fromDomainFull = getFullDomain(fromDomain, fromPort) fromDomainFull = get_full_domain(fromDomain, fromPort)
actor = local_actor_url(http_prefix, fromNickname, fromDomainFull) actor = local_actor_url(http_prefix, fromNickname, fromDomainFull)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
@ -1010,7 +1010,7 @@ def getSharedItemsCatalogViaServer(base_dir, session,
'Authorization': authHeader, 'Authorization': authHeader,
'Accept': 'application/json' 'Accept': 'application/json'
} }
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
url = local_actor_url(http_prefix, nickname, domain_full) + '/catalog' url = local_actor_url(http_prefix, nickname, domain_full) + '/catalog'
if debug: if debug:
print('Shared items catalog request to: ' + url) print('Shared items catalog request to: ' + url)
@ -1118,7 +1118,7 @@ def outboxUndoShareUpload(base_dir: str, http_prefix: str,
if debug: if debug:
print('DEBUG: displayName missing from Offer') print('DEBUG: displayName missing from Offer')
return return
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
removeSharedItem(base_dir, nickname, domain, removeSharedItem(base_dir, nickname, domain,
message_json['object']['displayName'], message_json['object']['displayName'],
http_prefix, domain_full, 'shares') http_prefix, domain_full, 'shares')

View File

@ -13,7 +13,7 @@ from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import hasObjectString from utils import hasObjectString
from utils import getFullDomain from utils import get_full_domain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -185,7 +185,7 @@ def sendSkillViaServer(base_dir: str, session, nickname: str, password: str,
print('WARN: No session for sendSkillViaServer') print('WARN: No session for sendSkillViaServer')
return 6 return 6
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
toUrl = actor toUrl = actor

View File

@ -11,7 +11,7 @@ from session import createSession
from webfinger import webfingerHandle from webfinger import webfingerHandle
from posts import getPersonBox from posts import getPersonBox
from posts import getPostDomains from posts import getPostDomains
from utils import getFullDomain from utils import get_full_domain
def instancesGraph(base_dir: str, handles: str, def instancesGraph(base_dir: str, handles: str,
@ -49,7 +49,7 @@ def instancesGraph(base_dir: str, handles: str,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
domain = handle.split('@')[1] domain = handle.split('@')[1]
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
handle = http_prefix + "://" + domain_full + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, webfingerHandle(session, handle, http_prefix,

View File

@ -69,7 +69,7 @@ from utils import validPassword
from utils import userAgentDomain from utils import userAgentDomain
from utils import camelCaseSplit from utils import camelCaseSplit
from utils import decoded_host from utils import decoded_host
from utils import getFullDomain from utils import get_full_domain
from utils import validNickname from utils import validNickname
from utils import firstParagraphFromString from utils import firstParagraphFromString
from utils import removeIdEnding from utils import removeIdEnding
@ -270,7 +270,7 @@ def _testHttpSignedGET(base_dir: str):
assert publicKeyPem assert publicKeyPem
messageBodyJsonStr = '' messageBodyJsonStr = ''
headersDomain = getFullDomain(hostDomain, port) headersDomain = get_full_domain(hostDomain, port)
dateStr = 'Tue, 14 Sep 2021 16:19:00 GMT' dateStr = 'Tue, 14 Sep 2021 16:19:00 GMT'
boxpath = '/inbox' boxpath = '/inbox'
@ -555,7 +555,7 @@ def _testHttpsigBase(withDigest: bool, base_dir: str):
else: else:
messageBodyJsonStr = '' messageBodyJsonStr = ''
headersDomain = getFullDomain(hostDomain, port) headersDomain = get_full_domain(hostDomain, port)
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
boxpath = '/inbox' boxpath = '/inbox'
@ -5939,7 +5939,7 @@ def _testHttpsigBaseNew(withDigest: bool, base_dir: str,
else: else:
messageBodyJsonStr = '' messageBodyJsonStr = ''
headersDomain = getFullDomain(hostDomain, port) headersDomain = get_full_domain(hostDomain, port)
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
boxpath = '/inbox' boxpath = '/inbox'

View File

@ -228,22 +228,22 @@ def valid_post_date(published: str, max_age_days: int, debug: bool) -> bool:
str(published)) str(published))
return False return False
daysDiff = post_time_object - baseline_time days_diff = post_time_object - baseline_time
postDaysSinceEpoch = daysDiff.days post_days_since_epoch = days_diff.days
if postDaysSinceEpoch > now_days_since_epoch: if post_days_since_epoch > now_days_since_epoch:
if debug: if debug:
print("Inbox post has a published date in the future!") print("Inbox post has a published date in the future!")
return False return False
if now_days_since_epoch - postDaysSinceEpoch >= max_age_days: if now_days_since_epoch - post_days_since_epoch >= max_age_days:
if debug: if debug:
print("Inbox post is not recent enough") print("Inbox post is not recent enough")
return False return False
return True return True
def getFullDomain(domain: str, port: int) -> str: def get_full_domain(domain: str, port: int) -> str:
"""Returns the full domain name, including port number """Returns the full domain name, including port number
""" """
if not port: if not port:

View File

@ -7,7 +7,7 @@ __email__ = "bob@libreserver.org"
__status__ = "Production" __status__ = "Production"
__module_group__ = "Timeline" __module_group__ = "Timeline"
from utils import getFullDomain from utils import get_full_domain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import removeIdEnding from utils import removeIdEnding
@ -67,7 +67,7 @@ def convertVideoToNote(base_dir: str, nickname: str, domain: str,
postDomain, postDomainPort = getDomainFromActor(attributedTo) postDomain, postDomainPort = getDomainFromActor(attributedTo)
if not postDomain: if not postDomain:
return None return None
postDomainFull = getFullDomain(postDomain, postDomainPort) postDomainFull = get_full_domain(postDomain, postDomainPort)
if isBlocked(base_dir, nickname, domain, if isBlocked(base_dir, nickname, domain,
postNickname, postDomainFull, blockedCache): postNickname, postDomainFull, blockedCache):
return None return None

View File

@ -9,7 +9,7 @@ __module_group__ = "Web Interface"
import os import os
from shutil import copyfile from shutil import copyfile
from utils import getFullDomain from utils import get_full_domain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import locatePost from utils import locatePost
@ -45,7 +45,7 @@ def htmlConfirmDelete(cssCache: {},
actor = messageId.split('/statuses/')[0] actor = messageId.split('/statuses/')[0]
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -114,7 +114,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
""" """
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
sharesFile = \ sharesFile = \
acct_dir(base_dir, nickname, domain) + '/' + sharesFileType + '.json' acct_dir(base_dir, nickname, domain) + '/' + sharesFileType + '.json'
if not os.path.isfile(sharesFile): if not os.path.isfile(sharesFile):

View File

@ -10,7 +10,7 @@ __module_group__ = "Moderation"
import os import os
from utils import isArtist from utils import isArtist
from utils import isAccountDir from utils import isAccountDir
from utils import getFullDomain from utils import get_full_domain
from utils import isEditor from utils import isEditor
from utils import loadJson from utils import loadJson
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -143,7 +143,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
for followerActor in followersList: for followerActor in followersList:
followerNickname = getNicknameFromActor(followerActor) followerNickname = getNicknameFromActor(followerActor)
followerDomain, followerPort = getDomainFromActor(followerActor) followerDomain, followerPort = getDomainFromActor(followerActor)
followerDomainFull = getFullDomain(followerDomain, followerPort) followerDomainFull = get_full_domain(followerDomain, followerPort)
if isBlocked(base_dir, nickname, domain, if isBlocked(base_dir, nickname, domain,
followerNickname, followerDomainFull): followerNickname, followerDomainFull):
blockedFollowers.append(followerActor) blockedFollowers.append(followerActor)
@ -157,7 +157,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
for followingActor in followingList: for followingActor in followingList:
followingNickname = getNicknameFromActor(followingActor) followingNickname = getNicknameFromActor(followingActor)
followingDomain, followingPort = getDomainFromActor(followingActor) followingDomain, followingPort = getDomainFromActor(followingActor)
followingDomainFull = getFullDomain(followingDomain, followingPort) followingDomainFull = get_full_domain(followingDomain, followingPort)
if isBlocked(base_dir, nickname, domain, if isBlocked(base_dir, nickname, domain,
followingNickname, followingDomainFull): followingNickname, followingDomainFull):
blockedFollowing.append(followingActor) blockedFollowing.append(followingActor)
@ -219,7 +219,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
followingNickname = getNicknameFromActor(actor) followingNickname = getNicknameFromActor(actor)
followingDomain, followingPort = getDomainFromActor(actor) followingDomain, followingPort = getDomainFromActor(actor)
followingDomainFull = \ followingDomainFull = \
getFullDomain(followingDomain, followingPort) get_full_domain(followingDomain, followingPort)
infoForm += '<a href="' + actor + '" ' + \ infoForm += '<a href="' + actor + '" ' + \
'target="_blank" rel="nofollow noopener noreferrer">' + \ 'target="_blank" rel="nofollow noopener noreferrer">' + \
followingNickname + '@' + followingDomainFull + \ followingNickname + '@' + followingDomainFull + \
@ -237,7 +237,7 @@ def htmlAccountInfo(cssCache: {}, translate: {},
for actor in blockedFollowers: for actor in blockedFollowers:
followerNickname = getNicknameFromActor(actor) followerNickname = getNicknameFromActor(actor)
followerDomain, followerPort = getDomainFromActor(actor) followerDomain, followerPort = getDomainFromActor(actor)
followerDomainFull = getFullDomain(followerDomain, followerPort) followerDomainFull = get_full_domain(followerDomain, followerPort)
infoForm += '<a href="' + actor + '" ' + \ infoForm += '<a href="' + actor + '" ' + \
'target="_blank" rel="nofollow noopener noreferrer">' + \ 'target="_blank" rel="nofollow noopener noreferrer">' + \
followerNickname + '@' + followerDomainFull + '</a><br><br>\n' followerNickname + '@' + followerDomainFull + '</a><br><br>\n'

View File

@ -12,7 +12,7 @@ from shutil import copyfile
from petnames import getPetName from petnames import getPetName
from person import isPersonSnoozed from person import isPersonSnoozed
from posts import isModerator from posts import isModerator
from utils import getFullDomain from utils import get_full_domain
from utils import getConfigParam from utils import getConfigParam
from utils import isDormant from utils import isDormant
from utils import removeHtml from utils import removeHtml
@ -66,7 +66,7 @@ def htmlPersonOptions(defaultTimeline: str,
"""Show options for a person: view/follow/block/report """Show options for a person: view/follow/block/report
""" """
optionsDomain, optionsPort = getDomainFromActor(optionsActor) optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = getFullDomain(optionsDomain, optionsPort) optionsDomainFull = get_full_domain(optionsDomain, optionsPort)
if os.path.isfile(base_dir + '/accounts/options-background-custom.jpg'): if os.path.isfile(base_dir + '/accounts/options-background-custom.jpg'):
if not os.path.isfile(base_dir + '/accounts/options-background.jpg'): if not os.path.isfile(base_dir + '/accounts/options-background.jpg'):
@ -97,7 +97,7 @@ def htmlPersonOptions(defaultTimeline: str,
dormant_months) dormant_months)
optionsNickname = getNicknameFromActor(optionsActor) optionsNickname = getNicknameFromActor(optionsActor)
optionsDomainFull = getFullDomain(optionsDomain, optionsPort) optionsDomainFull = get_full_domain(optionsDomain, optionsPort)
followsYou = \ followsYou = \
isFollowerOfPerson(base_dir, isFollowerOfPerson(base_dir,
nickname, domain, nickname, domain,

View File

@ -35,7 +35,7 @@ from utils import isDM
from utils import rejectPostId from utils import rejectPostId
from utils import isRecentPost from utils import isRecentPost
from utils import getConfigParam from utils import getConfigParam
from utils import getFullDomain from utils import get_full_domain
from utils import isEditor from utils import isEditor
from utils import locatePost from utils import locatePost
from utils import loadJson from utils import loadJson
@ -1381,7 +1381,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
if messageId: if messageId:
messageIdStr = ';' + messageId messageIdStr = ';' + messageId
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
pageNumberParam = '' pageNumberParam = ''
if pageNumber: if pageNumber:
@ -1426,7 +1426,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
# lookup the correct webfinger for the postActor # lookup the correct webfinger for the postActor
postActorNickname = getNicknameFromActor(postActor) postActorNickname = getNicknameFromActor(postActor)
postActorDomain, postActorPort = getDomainFromActor(postActor) postActorDomain, postActorPort = getDomainFromActor(postActor)
postActorDomainFull = getFullDomain(postActorDomain, postActorPort) postActorDomainFull = get_full_domain(postActorDomain, postActorPort)
postActorHandle = postActorNickname + '@' + postActorDomainFull postActorHandle = postActorNickname + '@' + postActorDomainFull
postActorWf = \ postActorWf = \
webfingerHandle(session, postActorHandle, http_prefix, webfingerHandle(session, postActorHandle, http_prefix,
@ -1848,7 +1848,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
post_json_object['object']['contentMap'][system_language] = \ post_json_object['object']['contentMap'][system_language] = \
post_json_object['object']['content'] post_json_object['object']['content']
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
personUrl = local_actor_url(http_prefix, nickname, domain_full) personUrl = local_actor_url(http_prefix, nickname, domain_full)
actor_json = \ actor_json = \
getPersonFromCache(base_dir, personUrl, person_cache, False) getPersonFromCache(base_dir, personUrl, person_cache, False)
@ -2025,7 +2025,7 @@ def htmlIndividualPost(cssCache: {},
if byStr: if byStr:
byStrNickname = getNicknameFromActor(byStr) byStrNickname = getNicknameFromActor(byStr)
byStrDomain, byStrPort = getDomainFromActor(byStr) byStrDomain, byStrPort = getDomainFromActor(byStr)
byStrDomain = getFullDomain(byStrDomain, byStrPort) byStrDomain = get_full_domain(byStrDomain, byStrPort)
byStrHandle = byStrNickname + '@' + byStrDomain byStrHandle = byStrNickname + '@' + byStrDomain
if translate.get(byText): if translate.get(byText):
byText = translate[byText] byText = translate[byText]
@ -2033,7 +2033,7 @@ def htmlIndividualPost(cssCache: {},
'<p>' + byText + ' <a href="' + byStr + '">@' + \ '<p>' + byText + ' <a href="' + byStr + '">@' + \
byStrHandle + '</a>' + byTextExtra + '\n' byStrHandle + '</a>' + byTextExtra + '\n'
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = '/users/' + nickname actor = '/users/' + nickname
followStr = ' <form method="POST" ' + \ followStr = ' <form method="POST" ' + \
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n' 'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'

View File

@ -15,7 +15,7 @@ from utils import isGroupAccount
from utils import has_object_dict from utils import has_object_dict
from utils import getOccupationName from utils import getOccupationName
from utils import get_locked_account from utils import get_locked_account
from utils import getFullDomain from utils import get_full_domain
from utils import isArtist from utils import isArtist
from utils import isDormant from utils import isDormant
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -162,7 +162,7 @@ def htmlProfileAfterSearch(cssCache: {},
searchNickname = getNicknameFromActor(personUrl) searchNickname = getNicknameFromActor(personUrl)
if not searchNickname: if not searchNickname:
return None return None
searchDomainFull = getFullDomain(searchDomain, searchPort) searchDomainFull = get_full_domain(searchDomain, searchPort)
profileStr = '' profileStr = ''
cssFilename = base_dir + '/epicyon-profile.css' cssFilename = base_dir + '/epicyon-profile.css'
@ -271,7 +271,7 @@ def htmlProfileAfterSearch(cssCache: {},
alsoKnownAs, accessKeys, alsoKnownAs, accessKeys,
joinedDate) joinedDate)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
followIsPermitted = True followIsPermitted = True
if not profile_json.get('followers'): if not profile_json.get('followers'):
@ -409,7 +409,7 @@ def _getProfileHeader(base_dir: str, http_prefix: str,
if movedTo: if movedTo:
newNickname = getNicknameFromActor(movedTo) newNickname = getNicknameFromActor(movedTo)
newDomain, newPort = getDomainFromActor(movedTo) newDomain, newPort = getDomainFromActor(movedTo)
newDomainFull = getFullDomain(newDomain, newPort) newDomainFull = get_full_domain(newDomain, newPort)
if newNickname and newDomain: if newNickname and newDomain:
htmlStr += \ htmlStr += \
' <p>' + translate['New account'] + ': ' + \ ' <p>' + translate['New account'] + ': ' + \
@ -503,7 +503,7 @@ def _getProfileHeaderAfterSearch(base_dir: str,
if movedTo: if movedTo:
newNickname = getNicknameFromActor(movedTo) newNickname = getNicknameFromActor(movedTo)
newDomain, newPort = getDomainFromActor(movedTo) newDomain, newPort = getDomainFromActor(movedTo)
newDomainFull = getFullDomain(newDomain, newPort) newDomainFull = get_full_domain(newDomain, newPort)
if newNickname and newDomain: if newNickname and newDomain:
newHandle = newNickname + '@' + newDomainFull newHandle = newNickname + '@' + newDomainFull
htmlStr += ' <p>' + translate['New account'] + \ htmlStr += ' <p>' + translate['New account'] + \
@ -596,7 +596,7 @@ def htmlProfile(signing_priv_key_pem: str,
addEmojiToDisplayName(session, base_dir, http_prefix, addEmojiToDisplayName(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profile_json['name'], True) profile_json['name'], True)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
profileDescription = \ profileDescription = \
addEmojiToDisplayName(session, base_dir, http_prefix, addEmojiToDisplayName(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
@ -2105,7 +2105,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
nickname = getNicknameFromActor(path) nickname = getNicknameFromActor(path)
if not nickname: if not nickname:
return '' return ''
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actorFilename = acct_dir(base_dir, nickname, domain) + '.json' actorFilename = acct_dir(base_dir, nickname, domain) + '.json'
if not os.path.isfile(actorFilename): if not os.path.isfile(actorFilename):
@ -2355,7 +2355,7 @@ def _individualFollowAsHtml(signing_priv_key_pem: str,
""" """
followUrlNickname = getNicknameFromActor(followUrl) followUrlNickname = getNicknameFromActor(followUrl)
followUrlDomain, followUrlPort = getDomainFromActor(followUrl) followUrlDomain, followUrlPort = getDomainFromActor(followUrl)
followUrlDomainFull = getFullDomain(followUrlDomain, followUrlPort) followUrlDomainFull = get_full_domain(followUrlDomain, followUrlPort)
titleStr = '@' + followUrlNickname + '@' + followUrlDomainFull titleStr = '@' + followUrlNickname + '@' + followUrlDomainFull
avatarUrl = getPersonAvatarUrl(base_dir, followUrl, person_cache, True) avatarUrl = getPersonAvatarUrl(base_dir, followUrl, person_cache, True)
if not avatarUrl: if not avatarUrl:

View File

@ -14,7 +14,7 @@ from datetime import datetime
from utils import get_base_content_from_post from utils import get_base_content_from_post
from utils import isAccountDir from utils import isAccountDir
from utils import getConfigParam from utils import getConfigParam
from utils import getFullDomain from utils import get_full_domain
from utils import isEditor from utils import isEditor
from utils import loadJson from utils import loadJson
from utils import getDomainFromActor from utils import getDomainFromActor
@ -629,7 +629,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, base_dir: str,
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# add the page title # add the page title
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
historySearchTitle = '🔍 ' + translate['Your Posts'] historySearchTitle = '🔍 ' + translate['Your Posts']
if boxName == 'bookmarks': if boxName == 'bookmarks':
@ -933,7 +933,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
if not lines: if not lines:
return None return None
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
maxFeedLength = 10 maxFeedLength = 10
hashtagFeed = \ hashtagFeed = \

View File

@ -13,7 +13,7 @@ from shutil import copyfile
from utils import isArtist from utils import isArtist
from utils import dangerousMarkup from utils import dangerousMarkup
from utils import getConfigParam from utils import getConfigParam
from utils import getFullDomain from utils import get_full_domain
from utils import isEditor from utils import isEditor
from utils import removeIdEnding from utils import removeIdEnding
from utils import acct_dir from utils import acct_dir
@ -611,7 +611,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
bookmarksButton = 'buttonselected' bookmarksButton = 'buttonselected'
# get the full domain, including any port number # get the full domain, including any port number
fullDomain = getFullDomain(domain, port) fullDomain = get_full_domain(domain, port)
usersPath = '/users/' + nickname usersPath = '/users/' + nickname
actor = http_prefix + '://' + fullDomain + usersPath actor = http_prefix + '://' + fullDomain + usersPath
@ -741,7 +741,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
' <tbody>\n' + \ ' <tbody>\n' + \
' <tr>\n' ' <tr>\n'
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
# left column # left column
leftColumnStr = \ leftColumnStr = \
@ -1053,7 +1053,7 @@ def _htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
sharesTimelineJson(actor, pageNumber, itemsPerPage, sharesTimelineJson(actor, pageNumber, itemsPerPage,
base_dir, domain, nickname, maxSharesPerAccount, base_dir, domain, nickname, maxSharesPerAccount,
shared_items_federated_domains, sharesFileType) shared_items_federated_domains, sharesFileType)
domain_full = getFullDomain(domain, port) domain_full = get_full_domain(domain, port)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
adminActor = '' adminActor = ''

View File

@ -12,7 +12,7 @@ import urllib.parse
from session import getJson from session import getJson
from cache import storeWebfingerInCache from cache import storeWebfingerInCache
from cache import getWebfingerFromCache from cache import getWebfingerFromCache
from utils import getFullDomain from utils import get_full_domain
from utils import loadJson from utils import loadJson
from utils import loadJsonOnionify from utils import loadJsonOnionify
from utils import saveJson from utils import saveJson
@ -116,7 +116,7 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Stores webfinger endpoint for a user to a file """Stores webfinger endpoint for a user to a file
""" """
originalDomain = domain originalDomain = domain
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
wfSubdir = '/wfendpoints' wfSubdir = '/wfendpoints'
if not os.path.isdir(base_dir + wfSubdir): if not os.path.isdir(base_dir + wfSubdir):
@ -136,7 +136,7 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Creates a webfinger endpoint for a user """Creates a webfinger endpoint for a user
""" """
originalDomain = domain originalDomain = domain
domain = getFullDomain(domain, port) domain = get_full_domain(domain, port)
personName = nickname personName = nickname
personId = local_actor_url(http_prefix, personName, domain) personId = local_actor_url(http_prefix, personName, domain)
@ -244,7 +244,7 @@ def webfingerLookup(path: str, base_dir: str,
if debug: if debug:
print('DEBUG: WEBFINGER no @ in handle ' + handle) print('DEBUG: WEBFINGER no @ in handle ' + handle)
return None return None
handle = getFullDomain(handle, port) handle = get_full_domain(handle, port)
# convert @domain@domain to inbox@domain # convert @domain@domain to inbox@domain
if '@' in handle: if '@' in handle:
handleDomain = handle.split('@')[1] handleDomain = handle.split('@')[1]