Snake case

main
Bob Mottram 2021-12-26 10:00:46 +00:00
parent db8465709e
commit 6abe5d83fe
47 changed files with 756 additions and 755 deletions

View File

@ -104,13 +104,13 @@ def outboxAnnounce(recentPostsCache: {},
def announcedByPerson(isAnnounced: bool, postActor: str, def announcedByPerson(isAnnounced: bool, postActor: str,
nickname: str, domainFull: str) -> bool: nickname: str, domain_full: str) -> bool:
"""Returns True if the given post is announced by the given person """Returns True if the given post is announced by the given person
""" """
if not postActor: if not postActor:
return False return False
if isAnnounced and \ if isAnnounced and \
postActor.endswith(domainFull + '/users/' + nickname): postActor.endswith(domain_full + '/users/' + nickname):
return True return True
return False return False
@ -315,9 +315,9 @@ def sendUndoAnnounceViaServer(base_dir: str, session,
print('WARN: No session for sendUndoAnnounceViaServer') print('WARN: No session for sendUndoAnnounceViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
handle = replaceUsersWithAt(actor) handle = replaceUsersWithAt(actor)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -374,7 +374,7 @@ def sendUndoAnnounceViaServer(base_dir: str, session,
'Content-type': 'application/json', 'Content-type': 'application/json',
'Authorization': authHeader 'Authorization': authHeader
} }
postResult = postJson(http_prefix, domainFull, postResult = postJson(http_prefix, domain_full,
session, unAnnounceJson, [], inboxUrl, session, unAnnounceJson, [], inboxUrl,
headers, 3, True) headers, 3, True)
if not postResult: if not postResult:

View File

@ -90,9 +90,9 @@ def sendAvailabilityViaServer(base_dir: str, session,
print('WARN: No session for sendAvailabilityViaServer') print('WARN: No session for sendAvailabilityViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
toUrl = localActorUrl(http_prefix, nickname, domainFull) toUrl = localActorUrl(http_prefix, nickname, domain_full)
ccUrl = toUrl + '/followers' ccUrl = toUrl + '/followers'
newAvailabilityJson = { newAvailabilityJson = {
@ -103,7 +103,7 @@ def sendAvailabilityViaServer(base_dir: str, session,
'cc': [ccUrl] 'cc': [ccUrl]
} }
handle = http_prefix + '://' + domainFull + '/@' + nickname handle = http_prefix + '://' + domain_full + '/@' + nickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, http_prefix, wfRequest = webfingerHandle(session, handle, http_prefix,
@ -148,7 +148,7 @@ def sendAvailabilityViaServer(base_dir: str, session,
'Content-type': 'application/json', 'Content-type': 'application/json',
'Authorization': authHeader 'Authorization': authHeader
} }
postResult = postJson(http_prefix, domainFull, postResult = postJson(http_prefix, domain_full,
session, newAvailabilityJson, [], session, newAvailabilityJson, [],
inboxUrl, headers, 30, True) inboxUrl, headers, 30, True)
if not postResult: if not postResult:

View File

@ -543,8 +543,8 @@ 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'])
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
if postJsonObj.get('conversation'): if postJsonObj.get('conversation'):
muteConversation(base_dir, nickname, domain, muteConversation(base_dir, nickname, domain,
@ -687,8 +687,8 @@ def unmutePost(base_dir: str, nickname: str, domain: str, port: int,
postJsonObj['conversation']) postJsonObj['conversation'])
if postJsonObj.get('ignores'): if postJsonObj.get('ignores'):
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
totalItems = 0 totalItems = 0
if postJsonObj['ignores'].get('totalItems'): if postJsonObj['ignores'].get('totalItems'):
totalItems = postJsonObj['ignores']['totalItems'] totalItems = postJsonObj['ignores']['totalItems']
@ -778,8 +778,8 @@ def outboxMute(base_dir: str, http_prefix: str,
return return
if not hasActor(message_json, debug): if not hasActor(message_json, debug):
return return
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if not message_json['actor'].endswith(domainFull + '/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':
return return
@ -827,8 +827,8 @@ def outboxUndoMute(base_dir: str, http_prefix: str,
return return
if not hasActor(message_json, debug): if not hasActor(message_json, debug):
return return
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if not message_json['actor'].endswith(domainFull + '/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':
return return
@ -880,7 +880,7 @@ def broch_modeIsActive(base_dir: str) -> bool:
return os.path.isfile(allowFilename) return os.path.isfile(allowFilename)
def setBrochMode(base_dir: str, domainFull: str, enabled: bool) -> None: def setBrochMode(base_dir: str, domain_full: str, enabled: bool) -> None:
"""Broch mode can be used to lock down the instance during """Broch mode can be used to lock down the instance during
a period of time when it is temporarily under attack. a period of time when it is temporarily under attack.
For example, where an adversary is constantly spinning up new For example, where an adversary is constantly spinning up new
@ -906,7 +906,7 @@ def setBrochMode(base_dir: str, domainFull: str, enabled: bool) -> None:
print('Broch mode already activated ' + lastModified) print('Broch mode already activated ' + lastModified)
return return
# generate instance allow list # generate instance allow list
allowedDomains = [domainFull] allowedDomains = [domain_full]
followFiles = ('following.txt', 'followers.txt') followFiles = ('following.txt', 'followers.txt')
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:
@ -935,7 +935,7 @@ def setBrochMode(base_dir: str, domainFull: str, enabled: bool) -> None:
# write the allow file # write the allow file
try: try:
with open(allowFilename, 'w+') as allowFile: with open(allowFilename, 'w+') as allowFile:
allowFile.write(domainFull + '\n') allowFile.write(domain_full + '\n')
for d in allowedDomains: for d in allowedDomains:
allowFile.write(d + '\n') allowFile.write(d + '\n')
print('Broch mode enabled') print('Broch mode enabled')

66
blog.py
View File

@ -40,7 +40,7 @@ from cache import getPersonFromCache
def _noOfBlogReplies(base_dir: str, http_prefix: str, translate: {}, def _noOfBlogReplies(base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
postId: str, depth=0) -> int: postId: str, depth=0) -> int:
"""Returns the number of replies on the post """Returns the number of replies on the post
This is recursive, so can handle replies to replies This is recursive, so can handle replies to replies
@ -85,7 +85,7 @@ def _noOfBlogReplies(base_dir: str, http_prefix: str, translate: {},
replyPostId = replyPostId.replace('.replies', '') replyPostId = replyPostId.replace('.replies', '')
replies += \ replies += \
1 + _noOfBlogReplies(base_dir, http_prefix, translate, 1 + _noOfBlogReplies(base_dir, http_prefix, translate,
nickname, domain, domainFull, nickname, domain, domain_full,
replyPostId, depth+1) replyPostId, depth+1)
else: else:
# remove post which no longer exists # remove post which no longer exists
@ -110,7 +110,7 @@ def _noOfBlogReplies(base_dir: str, http_prefix: str, translate: {},
def _getBlogReplies(base_dir: str, http_prefix: str, translate: {}, def _getBlogReplies(base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
postId: str, depth=0) -> str: postId: str, depth=0) -> str:
"""Returns a string containing html blog posts """Returns a string containing html blog posts
""" """
@ -170,7 +170,7 @@ def _getBlogReplies(base_dir: str, http_prefix: str, translate: {},
except OSError: except OSError:
print('EX: unable to read blog replies ' + postFilename) print('EX: unable to read blog replies ' + postFilename)
rply = _getBlogReplies(base_dir, http_prefix, translate, rply = _getBlogReplies(base_dir, http_prefix, translate,
nickname, domain, domainFull, nickname, domain, domain_full,
replyPostId, depth+1) replyPostId, depth+1)
if rply not in repliesStr: if rply not in repliesStr:
repliesStr += rply repliesStr += rply
@ -187,7 +187,7 @@ def _getBlogReplies(base_dir: str, http_prefix: str, translate: {},
def _htmlBlogPostContent(debug: bool, session, authorized: bool, def _htmlBlogPostContent(debug: bool, session, authorized: bool,
base_dir: str, http_prefix: str, translate: {}, base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, post_json_object: {},
handle: str, restrictToDomain: bool, handle: str, restrictToDomain: bool,
peertube_instances: [], peertube_instances: [],
@ -236,7 +236,7 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
if handle: if handle:
if handle.startswith(nickname + '@' + domain): if handle.startswith(nickname + '@' + domain):
blogStr += ' <a href="' + http_prefix + '://' + \ blogStr += ' <a href="' + http_prefix + '://' + \
domainFull + \ domain_full + \
'/users/' + nickname + '">' + handle + '</a>' '/users/' + nickname + '">' + handle + '</a>'
linkedAuthor = True linkedAuthor = True
else: else:
@ -265,7 +265,7 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
if attachmentStr: if attachmentStr:
blogStr += '<br><center>' + attachmentStr + '</center>' blogStr += '<br><center>' + attachmentStr + '</center>'
personUrl = localActorUrl(http_prefix, nickname, domainFull) personUrl = localActorUrl(http_prefix, nickname, domain_full)
actorJson = \ actorJson = \
getPersonFromCache(base_dir, personUrl, person_cache, False) getPersonFromCache(base_dir, personUrl, person_cache, False)
languagesUnderstood = [] languagesUnderstood = []
@ -311,12 +311,12 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
if not linkedAuthor: if not linkedAuthor:
blogStr += '<p class="about"><a class="about" href="' + \ blogStr += '<p class="about"><a class="about" href="' + \
localActorUrl(http_prefix, nickname, domainFull) + \ localActorUrl(http_prefix, nickname, domain_full) + \
'">' + translate['About the author'] + \ '">' + translate['About the author'] + \
'</a></p>\n' '</a></p>\n'
replies = _noOfBlogReplies(base_dir, http_prefix, translate, replies = _noOfBlogReplies(base_dir, http_prefix, translate,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object['object']['id']) post_json_object['object']['id'])
# separator between blogs should be centered # separator between blogs should be centered
@ -335,11 +335,11 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
blogStr += blogSeparator + '<h1>' + translate['Replies'] + '</h1>\n' blogStr += blogSeparator + '<h1>' + translate['Replies'] + '</h1>\n'
if not titleStr: if not titleStr:
blogStr += _getBlogReplies(base_dir, http_prefix, translate, blogStr += _getBlogReplies(base_dir, http_prefix, translate,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object['object']['id']) post_json_object['object']['id'])
else: else:
blogRepliesStr = _getBlogReplies(base_dir, http_prefix, translate, blogRepliesStr = _getBlogReplies(base_dir, http_prefix, translate,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object['object']['id']) post_json_object['object']['id'])
blogStr += blogRepliesStr.replace('>' + titleStr + '<', '') blogStr += blogRepliesStr.replace('>' + titleStr + '<', '')
@ -348,7 +348,7 @@ def _htmlBlogPostContent(debug: bool, session, authorized: bool,
def _htmlBlogPostRSS2(authorized: bool, def _htmlBlogPostRSS2(authorized: bool,
base_dir: str, http_prefix: str, translate: {}, base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, post_json_object: {},
handle: str, restrictToDomain: bool, handle: str, restrictToDomain: bool,
system_language: str) -> str: system_language: str) -> str:
@ -382,7 +382,7 @@ def _htmlBlogPostRSS2(authorized: bool,
def _htmlBlogPostRSS3(authorized: bool, def _htmlBlogPostRSS3(authorized: bool,
base_dir: str, http_prefix: str, translate: {}, base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, post_json_object: {},
handle: str, restrictToDomain: bool, handle: str, restrictToDomain: bool,
system_language: str) -> str: system_language: str) -> str:
@ -442,7 +442,7 @@ def _getSnippetFromBlogContent(post_json_object: {},
def htmlBlogPost(session, authorized: bool, def htmlBlogPost(session, authorized: bool,
base_dir: str, http_prefix: str, translate: {}, base_dir: str, http_prefix: str, translate: {},
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, post_json_object: {},
peertube_instances: [], peertube_instances: [],
system_language: str, person_cache: {}, system_language: str, person_cache: {},
@ -466,7 +466,7 @@ def htmlBlogPost(session, authorized: bool,
url = post_json_object['object']['url'] url = post_json_object['object']['url']
snippet = _getSnippetFromBlogContent(post_json_object, system_language) snippet = _getSnippetFromBlogContent(post_json_object, system_language)
blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle, blogStr = htmlHeaderWithBlogMarkup(cssFilename, instanceTitle,
http_prefix, domainFull, nickname, http_prefix, domain_full, nickname,
system_language, published, modified, system_language, published, modified,
title, snippet, translate, url, title, snippet, translate, url,
content_license_url) content_license_url)
@ -475,7 +475,7 @@ def htmlBlogPost(session, authorized: bool,
blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir, blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir,
http_prefix, translate, http_prefix, translate,
nickname, domain, nickname, domain,
domainFull, post_json_object, domain_full, post_json_object,
None, False, None, False,
peertube_instances, system_language, peertube_instances, system_language,
person_cache) person_cache)
@ -484,14 +484,14 @@ def htmlBlogPost(session, authorized: bool,
blogStr += '<p class="rssfeed">' blogStr += '<p class="rssfeed">'
blogStr += '<a href="' + http_prefix + '://' + \ blogStr += '<a href="' + http_prefix + '://' + \
domainFull + '/blog/' + nickname + '/rss.xml">' domain_full + '/blog/' + nickname + '/rss.xml">'
blogStr += '<img style="width:3%;min-width:50px" ' + \ blogStr += '<img style="width:3%;min-width:50px" ' + \
'loading="lazy" alt="RSS 2.0" ' + \ 'loading="lazy" alt="RSS 2.0" ' + \
'title="RSS 2.0" src="/' + \ 'title="RSS 2.0" src="/' + \
'icons/logorss.png" /></a>' 'icons/logorss.png" /></a>'
# blogStr += '<a href="' + http_prefix + '://' + \ # blogStr += '<a href="' + http_prefix + '://' + \
# domainFull + '/blog/' + nickname + '/rss.txt">' # domain_full + '/blog/' + nickname + '/rss.txt">'
# blogStr += '<img style="width:3%;min-width:50px" ' + \ # blogStr += '<img style="width:3%;min-width:50px" ' + \
# 'loading="lazy" alt="RSS 3.0" ' + \ # 'loading="lazy" alt="RSS 3.0" ' + \
# 'title="RSS 3.0" src="/' + \ # 'title="RSS 3.0" src="/' + \
@ -536,7 +536,7 @@ def htmlBlogPage(authorized: bool, session,
if not timelineJson: if not timelineJson:
return blogStr + htmlFooter() return blogStr + htmlFooter()
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
# show previous and next buttons # show previous and next buttons
if pageNumber is not None: if pageNumber is not None:
@ -544,7 +544,7 @@ def htmlBlogPage(authorized: bool, session,
if pageNumber > 1: if pageNumber > 1:
# show previous button # show previous button
navigateStr += '<a href="' + http_prefix + '://' + \ navigateStr += '<a href="' + http_prefix + '://' + \
domainFull + '/blog/' + \ domain_full + '/blog/' + \
nickname + '?page=' + str(pageNumber-1) + '">' + \ nickname + '?page=' + str(pageNumber-1) + '">' + \
'<img loading="lazy" alt="<" title="<" ' + \ '<img loading="lazy" alt="<" title="<" ' + \
'src="/icons' + \ 'src="/icons' + \
@ -552,7 +552,7 @@ def htmlBlogPage(authorized: bool, session,
if len(timelineJson['orderedItems']) >= noOfItems: if len(timelineJson['orderedItems']) >= noOfItems:
# show next button # show next button
navigateStr += '<a href="' + http_prefix + '://' + \ navigateStr += '<a href="' + http_prefix + '://' + \
domainFull + '/blog/' + nickname + \ domain_full + '/blog/' + nickname + \
'?page=' + str(pageNumber + 1) + '">' + \ '?page=' + str(pageNumber + 1) + '">' + \
'<img loading="lazy" alt=">" title=">" ' + \ '<img loading="lazy" alt=">" title=">" ' + \
'src="/icons' + \ 'src="/icons' + \
@ -567,7 +567,7 @@ def htmlBlogPage(authorized: bool, session,
blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir, blogStr += _htmlBlogPostContent(debug, session, authorized, base_dir,
http_prefix, translate, http_prefix, translate,
nickname, domain, nickname, domain,
domainFull, item, domain_full, item,
None, True, None, True,
peertube_instances, peertube_instances,
system_language, system_language,
@ -580,13 +580,13 @@ def htmlBlogPage(authorized: bool, session,
blogStr += '<p class="rssfeed">' blogStr += '<p class="rssfeed">'
blogStr += '<a href="' + http_prefix + '://' + \ blogStr += '<a href="' + http_prefix + '://' + \
domainFull + '/blog/' + nickname + '/rss.xml">' domain_full + '/blog/' + nickname + '/rss.xml">'
blogStr += '<img loading="lazy" alt="RSS 2.0" ' + \ blogStr += '<img loading="lazy" alt="RSS 2.0" ' + \
'title="RSS 2.0" src="/' + \ 'title="RSS 2.0" src="/' + \
'icons/logorss.png" /></a>' 'icons/logorss.png" /></a>'
# blogStr += '<a href="' + http_prefix + '://' + \ # blogStr += '<a href="' + http_prefix + '://' + \
# domainFull + '/blog/' + nickname + '/rss.txt">' # domain_full + '/blog/' + nickname + '/rss.txt">'
# blogStr += '<img loading="lazy" alt="RSS 3.0" ' + \ # blogStr += '<img loading="lazy" alt="RSS 3.0" ' + \
# 'title="RSS 3.0" src="/' + \ # 'title="RSS 3.0" src="/' + \
# 'icons/rss3.png" /></a>' # 'icons/rss3.png" /></a>'
@ -606,11 +606,11 @@ def htmlBlogPageRSS2(authorized: bool, session,
'\n' in nickname or '\r' in nickname: '\n' in nickname or '\r' in nickname:
return None return None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
blogRSS2 = '' blogRSS2 = ''
if includeHeader: if includeHeader:
blogRSS2 = rss2Header(http_prefix, nickname, domainFull, blogRSS2 = rss2Header(http_prefix, nickname, domain_full,
'Blog', translate) 'Blog', translate)
blogsIndex = acctDir(base_dir, nickname, domain) + '/tlblogs.index' blogsIndex = acctDir(base_dir, nickname, domain) + '/tlblogs.index'
@ -641,7 +641,7 @@ def htmlBlogPageRSS2(authorized: bool, session,
_htmlBlogPostRSS2(authorized, base_dir, _htmlBlogPostRSS2(authorized, base_dir,
http_prefix, translate, http_prefix, translate,
nickname, domain, nickname, domain,
domainFull, item, domain_full, item,
None, True, system_language) None, True, system_language)
if includeHeader: if includeHeader:
@ -661,7 +661,7 @@ def htmlBlogPageRSS3(authorized: bool, session,
'\n' in nickname or '\r' in nickname: '\n' in nickname or '\r' in nickname:
return None return None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
blogRSS3 = '' blogRSS3 = ''
@ -687,7 +687,7 @@ def htmlBlogPageRSS3(authorized: bool, session,
_htmlBlogPostRSS3(authorized, base_dir, _htmlBlogPostRSS3(authorized, base_dir,
http_prefix, translate, http_prefix, translate,
nickname, domain, nickname, domain,
domainFull, item, domain_full, item,
None, True, None, True,
system_language) system_language)
@ -751,7 +751,7 @@ def htmlBlogView(authorized: bool,
noOfItems, 1, peertube_instances, noOfItems, 1, peertube_instances,
system_language, person_cache, debug) system_language, person_cache, debug)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(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:
@ -762,7 +762,7 @@ def htmlBlogView(authorized: bool,
if os.path.isfile(blogsIndex): if os.path.isfile(blogsIndex):
blogStr += '<p class="blogaccount">' blogStr += '<p class="blogaccount">'
blogStr += '<a href="' + \ blogStr += '<a href="' + \
http_prefix + '://' + domainFull + '/blog/' + \ http_prefix + '://' + domain_full + '/blog/' + \
acct.split('@')[0] + '">' + acct + '</a>' acct.split('@')[0] + '">' + acct + '</a>'
blogStr += '</p>' blogStr += '</p>'
break break
@ -917,7 +917,7 @@ def htmlEditBlog(media_instance: bool, translate: {},
def pathContainsBlogLink(base_dir: str, def pathContainsBlogLink(base_dir: str,
http_prefix: str, domain: str, http_prefix: str, domain: str,
domainFull: str, path: str) -> (str, str): domain_full: str, path: str) -> (str, str):
"""If the path contains a blog entry then return its filename """If the path contains a blog entry then return its filename
""" """
if '/users/' not in path: if '/users/' not in path:
@ -940,7 +940,7 @@ def pathContainsBlogLink(base_dir: str,
return None, None return None, None
if '#' + userEnding2[1] + '.' not in open(blogIndexFilename).read(): if '#' + userEnding2[1] + '.' not in open(blogIndexFilename).read():
return None, None return None, None
messageId = localActorUrl(http_prefix, nickname, domainFull) + \ messageId = localActorUrl(http_prefix, nickname, domain_full) + \
'/statuses/' + userEnding2[1] '/statuses/' + userEnding2[1]
return locatePost(base_dir, nickname, domain, messageId), nickname return locatePost(base_dir, nickname, domain, messageId), nickname

View File

@ -383,9 +383,9 @@ def sendBookmarkViaServer(base_dir: str, session,
print('WARN: No session for sendBookmarkViaServer') print('WARN: No session for sendBookmarkViaServer')
return 6 return 6
domainFull = getFullDomain(domain, fromPort) domain_full = getFullDomain(domain, fromPort)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
newBookmarkJson = { newBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -400,7 +400,7 @@ def sendBookmarkViaServer(base_dir: str, session,
"target": actor + "/tlbookmarks" "target": actor + "/tlbookmarks"
} }
handle = http_prefix + '://' + domainFull + '/@' + nickname handle = http_prefix + '://' + domain_full + '/@' + nickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, http_prefix, wfRequest = webfingerHandle(session, handle, http_prefix,
@ -446,7 +446,7 @@ def sendBookmarkViaServer(base_dir: str, session,
'Content-type': 'application/json', 'Content-type': 'application/json',
'Authorization': authHeader 'Authorization': authHeader
} }
postResult = postJson(http_prefix, domainFull, postResult = postJson(http_prefix, domain_full,
session, newBookmarkJson, [], inboxUrl, session, newBookmarkJson, [], inboxUrl,
headers, 3, True) headers, 3, True)
if not postResult: if not postResult:
@ -473,9 +473,9 @@ def sendUndoBookmarkViaServer(base_dir: str, session,
print('WARN: No session for sendUndoBookmarkViaServer') print('WARN: No session for sendUndoBookmarkViaServer')
return 6 return 6
domainFull = getFullDomain(domain, fromPort) domain_full = getFullDomain(domain, fromPort)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
newBookmarkJson = { newBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -490,7 +490,7 @@ def sendUndoBookmarkViaServer(base_dir: str, session,
"target": actor + "/tlbookmarks" "target": actor + "/tlbookmarks"
} }
handle = http_prefix + '://' + domainFull + '/@' + nickname handle = http_prefix + '://' + domain_full + '/@' + nickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, http_prefix, wfRequest = webfingerHandle(session, handle, http_prefix,
@ -536,7 +536,7 @@ def sendUndoBookmarkViaServer(base_dir: str, session,
'Content-type': 'application/json', 'Content-type': 'application/json',
'Authorization': authHeader 'Authorization': authHeader
} }
postResult = postJson(http_prefix, domainFull, postResult = postJson(http_prefix, domain_full,
session, newBookmarkJson, [], inboxUrl, session, newBookmarkJson, [], inboxUrl,
headers, 3, True) headers, 3, True)
if not postResult: if not postResult:
@ -572,8 +572,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if not message_json['target'].endswith('://' + domainFull + if not message_json['target'].endswith('://' + domain_full +
'/users/' + nickname + '/users/' + nickname +
'/tlbookmarks'): '/tlbookmarks'):
if debug: if debug:
@ -628,8 +628,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if not message_json['target'].endswith('://' + domainFull + if not message_json['target'].endswith('://' + domain_full +
'/users/' + nickname + '/users/' + nickname +
'/tlbookmarks'): '/tlbookmarks'):
if debug: if debug:

View File

@ -33,7 +33,7 @@ def _removePersonFromCache(base_dir: str, personUrl: str,
def checkForChangedActor(session, base_dir: str, def checkForChangedActor(session, base_dir: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
personUrl: str, avatarUrl: str, person_cache: {}, personUrl: str, avatarUrl: str, person_cache: {},
timeoutSec: int): timeoutSec: int):
"""Checks if the avatar url exists and if not then """Checks if the avatar url exists and if not then
@ -43,9 +43,9 @@ def checkForChangedActor(session, base_dir: str,
""" """
if not session or not avatarUrl: if not session or not avatarUrl:
return return
if domainFull in avatarUrl: if domain_full in avatarUrl:
return return
if urlExists(session, avatarUrl, timeoutSec, http_prefix, domainFull): if urlExists(session, avatarUrl, timeoutSec, http_prefix, domain_full):
return return
_removePersonFromCache(base_dir, personUrl, person_cache) _removePersonFromCache(base_dir, personUrl, person_cache)

626
daemon.py

File diff suppressed because it is too large Load Diff

View File

@ -670,7 +670,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
system_language: str, system_language: str,
screenreader: str, espeak, screenreader: str, espeak,
translate: {}, yourActor: str, translate: {}, yourActor: str,
domainFull: str, person_cache: {}, domain_full: str, person_cache: {},
signing_priv_key_pem: str, signing_priv_key_pem: str,
blockedCache: {}) -> {}: blockedCache: {}) -> {}:
"""Reads a post from the given timeline """Reads a post from the given timeline
@ -711,7 +711,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
allow_local_network_access, allow_local_network_access,
recentPostsCache, False, recentPostsCache, False,
system_language, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
if post_json_object2: if post_json_object2:
@ -1408,8 +1408,8 @@ 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)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
yourActor = localActorUrl(http_prefix, nickname, domainFull) yourActor = localActorUrl(http_prefix, nickname, domain_full)
actorJson = None actorJson = None
notifyJson = { notifyJson = {
@ -1643,7 +1643,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
pageNumber, postIndex, boxJson, pageNumber, postIndex, boxJson,
system_language, screenreader, system_language, screenreader,
espeak, translate, yourActor, espeak, translate, yourActor,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
print('') print('')
@ -2415,7 +2415,7 @@ def runDesktopClient(base_dir: str, proxy_type: str, http_prefix: str,
allow_local_network_access, allow_local_network_access,
recentPostsCache, False, recentPostsCache, False,
system_language, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
if post_json_object2: if post_json_object2:

View File

@ -140,13 +140,13 @@ def E2EEaddDevice(base_dir: str, nickname: str, domain: str,
def E2EEdevicesCollection(base_dir: str, nickname: str, domain: str, def E2EEdevicesCollection(base_dir: str, nickname: str, domain: str,
domainFull: str, http_prefix: str) -> {}: domain_full: str, http_prefix: str) -> {}:
"""Returns a list of registered devices """Returns a list of registered devices
""" """
personDir = acctDir(base_dir, nickname, domain) personDir = acctDir(base_dir, nickname, domain)
if not os.path.isdir(personDir): if not os.path.isdir(personDir):
return {} return {}
personId = localActorUrl(http_prefix, nickname, domainFull) personId = localActorUrl(http_prefix, nickname, domain_full)
if not os.path.isdir(personDir + '/devices'): if not os.path.isdir(personDir + '/devices'):
os.mkdir(personDir + '/devices') os.mkdir(personDir + '/devices')
deviceList = [] deviceList = []

View File

@ -2980,19 +2980,19 @@ if args.testdata:
testEventDate, testEventTime, testLocation, testEventDate, testEventTime, testLocation,
testIsArticle, args.language, conversationId, testIsArticle, args.language, conversationId,
low_bandwidth, args.content_license_url) low_bandwidth, args.content_license_url)
domainFull = domain + ':' + str(port) domain_full = domain + ':' + str(port)
clearFollows(base_dir, nickname, domain) clearFollows(base_dir, nickname, domain)
followPerson(base_dir, nickname, domain, 'maxboardroom', domainFull, followPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,
federation_list, False, False) federation_list, False, False)
followPerson(base_dir, nickname, domain, 'ultrapancake', domainFull, followPerson(base_dir, nickname, domain, 'ultrapancake', domain_full,
federation_list, False, False) federation_list, False, False)
followPerson(base_dir, nickname, domain, 'sausagedog', domainFull, followPerson(base_dir, nickname, domain, 'sausagedog', domain_full,
federation_list, False, False) federation_list, False, False)
followPerson(base_dir, nickname, domain, 'drokk', domainFull, followPerson(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False) federation_list, False, False)
followerOfPerson(base_dir, nickname, domain, 'drokk', domainFull, followerOfPerson(base_dir, nickname, domain, 'drokk', domain_full,
federation_list, False, False) federation_list, False, False)
followerOfPerson(base_dir, nickname, domain, 'maxboardroom', domainFull, followerOfPerson(base_dir, nickname, domain, 'maxboardroom', domain_full,
federation_list, False, False) federation_list, False, False)
setConfigParam(base_dir, 'admin', nickname) setConfigParam(base_dir, 'admin', nickname)

View File

@ -8,13 +8,13 @@ __status__ = "Production"
__module_group__ = "RSS Feeds" __module_group__ = "RSS Feeds"
def rss2TagHeader(hashtag: str, http_prefix: str, domainFull: str) -> str: def rss2TagHeader(hashtag: str, http_prefix: str, domain_full: str) -> str:
return \ return \
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + \ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + \
"<rss version=\"2.0\">" + \ "<rss version=\"2.0\">" + \
'<channel>' + \ '<channel>' + \
' <title>#' + hashtag + '</title>' + \ ' <title>#' + hashtag + '</title>' + \
' <link>' + http_prefix + '://' + domainFull + \ ' <link>' + http_prefix + '://' + domain_full + \
'/tags/rss2/' + hashtag + '</link>' '/tags/rss2/' + hashtag + '</link>'

View File

@ -632,7 +632,7 @@ def storeFollowRequest(base_dir: str,
if not os.path.isdir(accountsDir): if not os.path.isdir(accountsDir):
return False return False
domainFull = getFullDomain(domain, fromPort) domain_full = getFullDomain(domain, fromPort)
approveHandle = getFullDomain(nickname + '@' + domain, fromPort) approveHandle = getFullDomain(nickname + '@' + domain, fromPort)
if group_account: if group_account:
@ -654,7 +654,7 @@ def storeFollowRequest(base_dir: str,
else: else:
usersPaths = getUserPaths() usersPaths = getUserPaths()
for possibleUsersPath in usersPaths: for possibleUsersPath in usersPaths:
url = '://' + domainFull + possibleUsersPath + nickname url = '://' + domain_full + possibleUsersPath + nickname
if url in followersStr: if url in followersStr:
alreadyFollowing = True alreadyFollowing = True
break break
@ -1137,8 +1137,8 @@ def getFollowingViaServer(base_dir: str, session,
print('WARN: No session for getFollowingViaServer') print('WARN: No session for getFollowingViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
followActor = localActorUrl(http_prefix, nickname, domainFull) followActor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1178,8 +1178,8 @@ def getFollowersViaServer(base_dir: str, session,
print('WARN: No session for getFollowersViaServer') print('WARN: No session for getFollowersViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
followActor = localActorUrl(http_prefix, nickname, domainFull) followActor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1219,9 +1219,9 @@ def getFollowRequestsViaServer(base_dir: str, session,
print('WARN: No session for getFollowRequestsViaServer') print('WARN: No session for getFollowRequestsViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
followActor = localActorUrl(http_prefix, nickname, domainFull) followActor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
headers = { headers = {
@ -1262,8 +1262,8 @@ def approveFollowRequestViaServer(base_dir: str, session,
print('WARN: No session for approveFollowRequestViaServer') print('WARN: No session for approveFollowRequestViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)
@ -1303,8 +1303,8 @@ def denyFollowRequestViaServer(base_dir: str, session,
print('WARN: No session for denyFollowRequestViaServer') print('WARN: No session for denyFollowRequestViaServer')
return 6 return 6
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)

View File

@ -155,7 +155,7 @@ def _storeLastPostId(base_dir: str, nickname: str, domain: str,
def _updateCachedHashtagSwarm(base_dir: str, nickname: str, domain: str, def _updateCachedHashtagSwarm(base_dir: str, nickname: str, domain: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
translate: {}) -> bool: translate: {}) -> bool:
"""Updates the hashtag swarm stored as a file """Updates the hashtag swarm stored as a file
""" """
@ -186,7 +186,7 @@ def _updateCachedHashtagSwarm(base_dir: str, nickname: str, domain: str,
else: else:
print('WARN: no modified date for ' + str(lastModified)) print('WARN: no modified date for ' + str(lastModified))
if saveSwarm: if saveSwarm:
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
newSwarmStr = htmlHashTagSwarm(base_dir, actor, translate) newSwarmStr = htmlHashTagSwarm(base_dir, actor, translate)
if newSwarmStr: if newSwarmStr:
try: try:
@ -200,7 +200,7 @@ def _updateCachedHashtagSwarm(base_dir: str, nickname: str, domain: str,
def storeHashTags(base_dir: str, nickname: str, domain: str, def storeHashTags(base_dir: str, nickname: str, domain: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
post_json_object: {}, translate: {}) -> None: post_json_object: {}, translate: {}) -> None:
"""Extracts hashtags from an incoming post and updates the """Extracts hashtags from an incoming post and updates the
relevant tags files. relevant tags files.
@ -275,7 +275,7 @@ def storeHashTags(base_dir: str, nickname: str, domain: str,
# ready for later display # ready for later display
if hashtagsCtr > 0: if hashtagsCtr > 0:
_updateCachedHashtagSwarm(base_dir, nickname, domain, _updateCachedHashtagSwarm(base_dir, nickname, domain,
http_prefix, domainFull, translate) http_prefix, domain_full, translate)
def _inboxStorePostToHtmlCache(recentPostsCache: {}, max_recent_posts: int, def _inboxStorePostToHtmlCache(recentPostsCache: {}, max_recent_posts: int,
@ -834,7 +834,7 @@ 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))
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
updateDomainFull = getFullDomain(updateDomain, updatePort) updateDomainFull = getFullDomain(updateDomain, updatePort)
usersPaths = getUserPaths() usersPaths = getUserPaths()
usersStrFound = False usersStrFound = False
@ -849,7 +849,7 @@ def _personReceiveUpdate(base_dir: str,
print('id: ' + personJson['id']) print('id: ' + personJson['id'])
print('DEBUG: Actor does not match id') print('DEBUG: Actor does not match id')
return False return False
if updateDomainFull == domainFull: if updateDomainFull == domain_full:
if debug: if debug:
print('DEBUG: You can only receive actor updates ' + print('DEBUG: You can only receive actor updates ' +
'for domains other than your own') 'for domains other than your own')
@ -1536,9 +1536,9 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if not message_json['actor'].endswith(domainFull + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
if debug: if debug:
print('DEBUG: inbox bookmark Add unexpected actor') print('DEBUG: inbox bookmark Add unexpected actor')
return False return False
@ -1648,9 +1648,9 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if not message_json['actor'].endswith(domainFull + '/users/' + nickname): if not message_json['actor'].endswith(domain_full + '/users/' + nickname):
if debug: if debug:
print('DEBUG: inbox undo bookmark Remove unexpected actor') print('DEBUG: inbox undo bookmark Remove unexpected actor')
return False return False
@ -1741,8 +1741,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
deletePrefix = http_prefix + '://' + domainFull + '/' 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
not message_json['actor'].startswith(deletePrefix))): not message_json['actor'].startswith(deletePrefix))):
@ -1788,7 +1788,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, base_dir: str,
print('DEBUG: post deleted - ' + postFilename) print('DEBUG: post deleted - ' + postFilename)
# also delete any local blogs saved to the news actor # also delete any local blogs saved to the news actor
if handleNickname != 'news' and handleDomain == domainFull: if handleNickname != 'news' and handleDomain == domain_full:
postFilename = locatePost(base_dir, 'news', postFilename = locatePost(base_dir, 'news',
handleDomain, messageId) handleDomain, messageId)
if postFilename: if postFilename:
@ -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'])
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
# Generate html. This also downloads the announced post. # Generate html. This also downloads the announced post.
pageNumber = 1 pageNumber = 1
@ -1947,7 +1947,7 @@ def _receiveAnnounce(recentPostsCache: {},
allow_local_network_access, allow_local_network_access,
recentPostsCache, debug, recentPostsCache, debug,
system_language, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
if not post_json_object: if not post_json_object:
@ -1969,7 +1969,7 @@ def _receiveAnnounce(recentPostsCache: {},
print('DEBUG: Announce post downloaded for ' + print('DEBUG: Announce post downloaded for ' +
message_json['actor'] + ' -> ' + message_json['object']) message_json['actor'] + ' -> ' + message_json['object'])
storeHashTags(base_dir, nickname, domain, storeHashTags(base_dir, nickname, domain,
http_prefix, domainFull, http_prefix, domain_full,
post_json_object, translate) post_json_object, translate)
# Try to obtain the actor for this person # Try to obtain the actor for this person
# so that their avatar can be shown # so that their avatar can be shown
@ -1990,9 +1990,9 @@ 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'):
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
updateSpeaker(base_dir, http_prefix, updateSpeaker(base_dir, http_prefix,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
translate, lookupActor, translate, lookupActor,
theme_name) theme_name)
@ -2197,7 +2197,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
message_json: {}, max_mentions: int, max_emoji: int, message_json: {}, max_mentions: int, max_emoji: int,
allow_local_network_access: bool, debug: bool, allow_local_network_access: bool, debug: bool,
system_language: str, system_language: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
person_cache: {}) -> bool: person_cache: {}) -> bool:
"""Is the content of a received post valid? """Is the content of a received post valid?
Check for bad html Check for bad html
@ -2273,7 +2273,7 @@ def _validPostContent(base_dir: str, nickname: str, domain: str,
# check that the post is in a language suitable for this account # check that the post is in a language suitable for this account
if not understoodPostLanguage(base_dir, nickname, domain, if not understoodPostLanguage(base_dir, nickname, domain,
message_json, system_language, message_json, system_language,
http_prefix, domainFull, http_prefix, domain_full,
person_cache): person_cache):
return False return False
# check for filtered content # check for filtered content
@ -2650,8 +2650,8 @@ 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]
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
groupActor = localActorUrl(http_prefix, nickname, domainFull) groupActor = localActorUrl(http_prefix, nickname, domain_full)
if groupActor not in post_json_object['to']: if groupActor not in post_json_object['to']:
return return
cc = '' cc = ''
@ -3422,12 +3422,12 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
jsonObj = None jsonObj = None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(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,
system_language, http_prefix, system_language, http_prefix,
domainFull, person_cache): domain_full, person_cache):
# is the sending actor valid? # is the sending actor valid?
if not validSendingActor(session, base_dir, nickname, domain, if not validSendingActor(session, base_dir, nickname, domain,
person_cache, post_json_object, person_cache, post_json_object,
@ -3495,7 +3495,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
return False return False
# get the actor being replied to # get the actor being replied to
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
# create a reply notification file if needed # create a reply notification file if needed
isReplyToMutedPost = \ isReplyToMutedPost = \
@ -3512,7 +3512,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
twitter_replacement_domain, twitter_replacement_domain,
allow_local_network_access, allow_local_network_access,
recentPostsCache, debug, system_language, recentPostsCache, debug, system_language,
domainFull, person_cache, signing_priv_key_pem): domain_full, person_cache, signing_priv_key_pem):
# media index will be updated # media index will be updated
updateIndexList.append('tlmedia') updateIndexList.append('tlmedia')
if isBlogPost(post_json_object): if isBlogPost(post_json_object):
@ -3550,9 +3550,9 @@ 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):
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
updateSpeaker(base_dir, http_prefix, updateSpeaker(base_dir, http_prefix,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
translate, None, theme_name) translate, None, theme_name)
if not unit_test: if not unit_test:
@ -3610,7 +3610,7 @@ def _inboxAfterInitial(recentPostsCache: {}, max_recent_posts: int,
_inboxUpdateCalendar(base_dir, handle, post_json_object) _inboxUpdateCalendar(base_dir, handle, post_json_object)
storeHashTags(base_dir, handleName, domain, storeHashTags(base_dir, handleName, domain,
http_prefix, domainFull, http_prefix, domain_full,
post_json_object, translate) post_json_object, translate)
# send the post out to group members # send the post out to group members
@ -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
domainFull = getFullDomain(domain, tempPort) domain_full = getFullDomain(domain, tempPort)
if tempPort: if tempPort:
fromPort = tempPort fromPort = tempPort
if not domainPermitted(domain, federation_list): if not domainPermitted(domain, federation_list):
@ -3929,14 +3929,14 @@ def _receiveFollowRequest(session, base_dir: str, http_prefix: str,
if isFollowerOfPerson(base_dir, if isFollowerOfPerson(base_dir,
nicknameToFollow, domainToFollowFull, nicknameToFollow, domainToFollowFull,
nickname, domainFull): nickname, domain_full):
if debug: if debug:
print('DEBUG: ' + nickname + '@' + domain + print('DEBUG: ' + nickname + '@' + domain +
' is already a follower of ' + ' is already a follower of ' +
nicknameToFollow + '@' + domainToFollow) nicknameToFollow + '@' + domainToFollow)
return True return True
approveHandle = nickname + '@' + domainFull approveHandle = nickname + '@' + domain_full
# is the actor sending the request valid? # is the actor sending the request valid?
if not validSendingActor(session, base_dir, if not validSendingActor(session, base_dir,

View File

@ -91,7 +91,7 @@ def setActorLanguages(base_dir: str, actorJson: {}, languagesStr: str) -> None:
def understoodPostLanguage(base_dir: str, nickname: str, domain: str, def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
message_json: {}, system_language: str, message_json: {}, system_language: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
person_cache: {}) -> bool: person_cache: {}) -> bool:
"""Returns true if the post is written in a language """Returns true if the post is written in a language
understood by this account understood by this account
@ -105,7 +105,7 @@ def understoodPostLanguage(base_dir: str, nickname: str, domain: str,
return True return True
if msgObject['contentMap'].get(system_language): if msgObject['contentMap'].get(system_language):
return True return True
personUrl = localActorUrl(http_prefix, nickname, domainFull) personUrl = localActorUrl(http_prefix, nickname, domain_full)
actorJson = getPersonFromCache(base_dir, personUrl, person_cache, False) actorJson = getPersonFromCache(base_dir, personUrl, person_cache, False)
if not actorJson: if not actorJson:
print('WARN: unable to load actor to check languages ' + personUrl) print('WARN: unable to load actor to check languages ' + personUrl)

View File

@ -86,7 +86,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
authorized: bool, authorized: bool,
http_prefix: str, http_prefix: str,
base_dir: str, nickname: str, domain: str, base_dir: str, nickname: str, domain: str,
domainFull: str, domain_full: str,
onion_domain: str, i2p_domain: str, onion_domain: str, i2p_domain: str,
translate: {}, translate: {},
registration: bool, registration: bool,
@ -209,10 +209,10 @@ def mastoApiV1Response(path: str, callingDomain: str,
instanceTitle = getConfigParam(base_dir, 'instanceTitle') instanceTitle = getConfigParam(base_dir, 'instanceTitle')
if callingDomain.endswith('.onion') and onion_domain: if callingDomain.endswith('.onion') and onion_domain:
domainFull = onion_domain domain_full = onion_domain
http_prefix = 'http' http_prefix = 'http'
elif (callingDomain.endswith('.i2p') and i2p_domain): elif (callingDomain.endswith('.i2p') and i2p_domain):
domainFull = i2p_domain domain_full = i2p_domain
http_prefix = 'http' http_prefix = 'http'
if broch_mode: if broch_mode:
@ -227,7 +227,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
base_dir, base_dir,
adminNickname, adminNickname,
domain, domain,
domainFull, domain_full,
registration, registration,
system_language, system_language,
project_version) project_version)
@ -238,7 +238,7 @@ def mastoApiV1Response(path: str, callingDomain: str,
# On a large instance you are somewhat lost in the crowd, but on # On a large instance you are somewhat lost in the crowd, but on
# small instances a full list of peers would convey a lot of # small instances a full list of peers would convey a lot of
# information about the interests of a small number of accounts # information about the interests of a small number of accounts
sendJson = ['mastodon.social', domainFull] sendJson = ['mastodon.social', domain_full]
sendJsonStr = 'masto API peers metadata sent ' + uaStr sendJsonStr = 'masto API peers metadata sent ' + uaStr
elif path.startswith('/api/v1/instance/activity'): elif path.startswith('/api/v1/instance/activity'):
sendJson = [] sendJson = []

View File

@ -86,7 +86,7 @@ def metaDataInstance(showAccounts: bool,
instanceDescriptionShort: str, instanceDescriptionShort: str,
instanceDescription: str, instanceDescription: str,
http_prefix: str, base_dir: str, http_prefix: str, base_dir: str,
adminNickname: str, domain: str, domainFull: str, adminNickname: str, domain: str, domain_full: str,
registration: bool, system_language: str, registration: bool, system_language: str,
version: str) -> {}: version: str) -> {}:
""" /api/v1/instance endpoint """ /api/v1/instance endpoint
@ -128,7 +128,7 @@ def metaDataInstance(showAccounts: bool,
isBot = True isBot = True
url = \ url = \
http_prefix + '://' + domainFull + '/@' + \ http_prefix + '://' + domain_full + '/@' + \
adminActor['preferredUsername'] adminActor['preferredUsername']
if showAccounts: if showAccounts:
@ -170,9 +170,9 @@ def metaDataInstance(showAccounts: bool,
'status_count': localPosts, 'status_count': localPosts,
'user_count': activeAccounts 'user_count': activeAccounts
}, },
'thumbnail': http_prefix + '://' + domainFull + '/login.png', 'thumbnail': http_prefix + '://' + domain_full + '/login.png',
'title': instanceTitle, 'title': instanceTitle,
'uri': domainFull, 'uri': domain_full,
'urls': {}, 'urls': {},
'version': version, 'version': version,
'rules': rulesList, 'rules': rulesList,
@ -208,13 +208,13 @@ def metaDataInstance(showAccounts: bool,
def metadataCustomEmoji(base_dir: str, def metadataCustomEmoji(base_dir: str,
http_prefix: str, domainFull: str) -> {}: http_prefix: str, domain_full: str) -> {}:
"""Returns the custom emoji """Returns the custom emoji
Endpoint /api/v1/custom_emojis Endpoint /api/v1/custom_emojis
See https://docs.joinmastodon.org/methods/instance/custom_emojis See https://docs.joinmastodon.org/methods/instance/custom_emojis
""" """
result = [] result = []
emojisUrl = http_prefix + '://' + domainFull + '/emoji' emojisUrl = http_prefix + '://' + domain_full + '/emoji'
for subdir, dirs, files in os.walk(base_dir + '/emoji'): for subdir, dirs, files in os.walk(base_dir + '/emoji'):
for f in files: for f in files:
if len(f) < 3: if len(f) < 3:

View File

@ -285,7 +285,7 @@ def hashtagRuleTree(operators: [],
return tree return tree
def _hashtagAdd(base_dir: str, http_prefix: str, domainFull: str, def _hashtagAdd(base_dir: str, http_prefix: str, domain_full: str,
post_json_object: {}, post_json_object: {},
actionStr: str, hashtags: [], system_language: str, actionStr: str, hashtags: [], system_language: str,
translate: {}) -> None: translate: {}) -> None:
@ -301,7 +301,7 @@ def _hashtagAdd(base_dir: str, http_prefix: str, domainFull: str,
if not validHashTag(htId): if not validHashTag(htId):
return return
hashtagUrl = http_prefix + "://" + domainFull + "/tags/" + htId hashtagUrl = http_prefix + "://" + domain_full + "/tags/" + htId
newTag = { newTag = {
'href': hashtagUrl, 'href': hashtagUrl,
'name': addHashtag, 'name': addHashtag,
@ -333,15 +333,15 @@ def _hashtagAdd(base_dir: str, http_prefix: str, domainFull: str,
else: else:
content += hashtagHtml content += hashtagHtml
post_json_object['object']['content'] = content post_json_object['object']['content'] = content
domain = domainFull domain = domain_full
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
storeHashTags(base_dir, 'news', domain, storeHashTags(base_dir, 'news', domain,
http_prefix, domainFull, http_prefix, domain_full,
post_json_object, translate) post_json_object, translate)
def _hashtagRemove(http_prefix: str, domainFull: str, post_json_object: {}, def _hashtagRemove(http_prefix: str, domain_full: str, post_json_object: {},
actionStr: str, hashtags: [], system_language: str) -> None: actionStr: str, hashtags: [], system_language: str) -> None:
"""Removes a hashtag via a hashtag rule """Removes a hashtag via a hashtag rule
""" """
@ -352,7 +352,7 @@ def _hashtagRemove(http_prefix: str, domainFull: str, post_json_object: {},
if rmHashtag in hashtags: if rmHashtag in hashtags:
hashtags.remove(rmHashtag) hashtags.remove(rmHashtag)
htId = rmHashtag.replace('#', '') htId = rmHashtag.replace('#', '')
hashtagUrl = http_prefix + "://" + domainFull + "/tags/" + htId hashtagUrl = http_prefix + "://" + domain_full + "/tags/" + htId
# remove tag html from the post content # remove tag html from the post content
hashtagHtml = \ hashtagHtml = \
"<a href=\"" + hashtagUrl + "\" class=\"addedHashtag\" " + \ "<a href=\"" + hashtagUrl + "\" class=\"addedHashtag\" " + \
@ -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()
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
# get the full text content of the post # get the full text content of the post
content = '' content = ''
@ -425,12 +425,12 @@ def _newswireHashtagProcessing(session, base_dir: str, post_json_object: {},
if actionStr.startswith('add '): if actionStr.startswith('add '):
# add a hashtag # add a hashtag
_hashtagAdd(base_dir, http_prefix, domainFull, _hashtagAdd(base_dir, http_prefix, domain_full,
post_json_object, actionStr, hashtags, system_language, post_json_object, actionStr, hashtags, system_language,
translate) translate)
elif actionStr.startswith('remove '): elif actionStr.startswith('remove '):
# remove a hashtag # remove a hashtag
_hashtagRemove(http_prefix, domainFull, post_json_object, _hashtagRemove(http_prefix, domain_full, post_json_object,
actionStr, hashtags, system_language) actionStr, hashtags, system_language)
elif actionStr.startswith('block') or actionStr.startswith('drop'): elif actionStr.startswith('block') or actionStr.startswith('drop'):
# Block this item # Block this item
@ -671,7 +671,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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
hashtags = item[6] hashtags = item[6]
@ -696,7 +696,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str,
for tagName in hashtags: for tagName in hashtags:
htId = tagName.replace('#', '') htId = tagName.replace('#', '')
hashtagUrl = \ hashtagUrl = \
http_prefix + "://" + domainFull + "/tags/" + htId http_prefix + "://" + domain_full + "/tags/" + htId
newTag = { newTag = {
'href': hashtagUrl, 'href': hashtagUrl,
'name': tagName, 'name': tagName,
@ -726,7 +726,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str,
newswire[originalDateStr][6].append(tag) newswire[originalDateStr][6].append(tag)
storeHashTags(base_dir, 'news', domain, storeHashTags(base_dir, 'news', domain,
http_prefix, domainFull, http_prefix, domain_full,
blog, translate) blog, translate)
clearFromPostCaches(base_dir, recentPostsCache, postId) clearFromPostCaches(base_dir, recentPostsCache, postId)

View File

@ -50,7 +50,7 @@ def _removeCDATA(text: str) -> str:
def rss2Header(http_prefix: str, def rss2Header(http_prefix: str,
nickname: str, domainFull: str, nickname: str, domain_full: str,
title: str, translate: {}) -> str: title: str, translate: {}) -> str:
"""Header for an RSS 2.0 feed """Header for an RSS 2.0 feed
""" """
@ -62,18 +62,18 @@ def rss2Header(http_prefix: str,
if title.startswith('News'): if title.startswith('News'):
rssStr += \ rssStr += \
' <title>Newswire</title>' + \ ' <title>Newswire</title>' + \
' <link>' + http_prefix + '://' + domainFull + \ ' <link>' + http_prefix + '://' + domain_full + \
'/newswire.xml' + '</link>' '/newswire.xml' + '</link>'
elif title.startswith('Site'): elif title.startswith('Site'):
rssStr += \ rssStr += \
' <title>' + domainFull + '</title>' + \ ' <title>' + domain_full + '</title>' + \
' <link>' + http_prefix + '://' + domainFull + \ ' <link>' + http_prefix + '://' + domain_full + \
'/blog/rss.xml' + '</link>' '/blog/rss.xml' + '</link>'
else: else:
rssStr += \ rssStr += \
' <title>' + translate[title] + '</title>' + \ ' <title>' + translate[title] + '</title>' + \
' <link>' + \ ' <link>' + \
localActorUrl(http_prefix, nickname, domainFull) + \ localActorUrl(http_prefix, nickname, domain_full) + \
'/rss.xml' + '</link>' '/rss.xml' + '</link>'
return rssStr return rssStr
@ -920,13 +920,13 @@ def getRSS(base_dir: str, domain: str, session, url: str,
def getRSSfromDict(base_dir: str, newswire: {}, def getRSSfromDict(base_dir: str, newswire: {},
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
title: str, translate: {}) -> str: title: str, translate: {}) -> str:
"""Returns an rss feed from the current newswire dict. """Returns an rss feed from the current newswire dict.
This allows other instances to subscribe to the same newswire This allows other instances to subscribe to the same newswire
""" """
rssStr = rss2Header(http_prefix, rssStr = rss2Header(http_prefix,
None, domainFull, None, domain_full,
'Newswire', translate) 'Newswire', translate)
if not newswire: if not newswire:
return '' return ''
@ -950,8 +950,8 @@ def getRSSfromDict(base_dir: str, newswire: {},
rssStr += ' <description>' + description + '</description>\n' rssStr += ' <description>' + description + '</description>\n'
url = fields[1] url = fields[1]
if '://' not in url: if '://' not in url:
if domainFull not in url: if domain_full not in url:
url = http_prefix + '://' + domainFull + url url = http_prefix + '://' + domain_full + url
rssStr += ' <link>' + url + '</link>\n' rssStr += ' <link>' + url + '</link>\n'
rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT") rssDateStr = pubDate.strftime("%a, %d %b %Y %H:%M:%S UT")

View File

@ -100,8 +100,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
if len(message_json['to']) != 1: if len(message_json['to']) != 1:
if debug: if debug:
print('DEBUG: c2s actor update - to does not contain one actor ' + print('DEBUG: c2s actor update - to does not contain one actor ' +
@ -180,7 +180,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
def postMessageToOutbox(session, translate: {}, def postMessageToOutbox(session, translate: {},
message_json: {}, postToNickname: str, message_json: {}, postToNickname: str,
server, base_dir: str, http_prefix: str, server, base_dir: str, http_prefix: str,
domain: str, domainFull: str, domain: str, domain_full: str,
onion_domain: str, i2p_domain: str, port: int, onion_domain: str, i2p_domain: str, port: int,
recentPostsCache: {}, followers_threads: [], recentPostsCache: {}, followers_threads: [],
federation_list: [], send_threads: [], federation_list: [], send_threads: [],
@ -335,7 +335,7 @@ def postMessageToOutbox(session, translate: {},
os.rename(uploadMediaFilename, mediaFilename) os.rename(uploadMediaFilename, mediaFilename)
# change the url of the attachment # change the url of the attachment
attach['url'] = \ attach['url'] = \
http_prefix + '://' + domainFull + '/' + mediaPath http_prefix + '://' + domain_full + '/' + mediaPath
attach['url'] = \ attach['url'] = \
attach['url'].replace('/media/', attach['url'].replace('/media/',
'/system/' + '/system/' +
@ -374,7 +374,7 @@ def postMessageToOutbox(session, translate: {},
savePostToBox(base_dir, savePostToBox(base_dir,
http_prefix, http_prefix,
postId, postId,
postToNickname, domainFull, postToNickname, domain_full,
message_json, outboxName) message_json, outboxName)
if not savedFilename: if not savedFilename:
print('WARN: post not saved to outbox ' + outboxName) print('WARN: post not saved to outbox ' + outboxName)
@ -413,7 +413,7 @@ def postMessageToOutbox(session, translate: {},
if message_json['type'] in indexedActivities: if message_json['type'] in indexedActivities:
indexes = [outboxName, "inbox"] indexes = [outboxName, "inbox"]
selfActor = \ selfActor = \
localActorUrl(http_prefix, postToNickname, domainFull) localActorUrl(http_prefix, postToNickname, domain_full)
for boxNameIndex in indexes: for boxNameIndex in indexes:
if not boxNameIndex: if not boxNameIndex:
continue continue
@ -428,7 +428,7 @@ def postMessageToOutbox(session, translate: {},
twitter_replacement_domain, twitter_replacement_domain,
allow_local_network_access, allow_local_network_access,
recentPostsCache, debug, system_language, recentPostsCache, debug, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem): signing_priv_key_pem):
inboxUpdateIndex('tlmedia', base_dir, inboxUpdateIndex('tlmedia', base_dir,
postToNickname + '@' + domain, postToNickname + '@' + domain,

View File

@ -1114,13 +1114,13 @@ def canRemovePost(base_dir: str, nickname: str,
if '/statuses/' not in postId: if '/statuses/' not in postId:
return False return False
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
# is the post by the admin? # is the post by the admin?
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
if not adminNickname: if not adminNickname:
return False return False
if domainFull + '/users/' + adminNickname + '/' in postId: if domain_full + '/users/' + adminNickname + '/' in postId:
return False return False
# is the post by a moderator? # is the post by a moderator?
@ -1129,7 +1129,7 @@ def canRemovePost(base_dir: str, nickname: str,
with open(moderatorsFile, 'r') as f: with open(moderatorsFile, 'r') as f:
lines = f.readlines() lines = f.readlines()
for moderator in lines: for moderator in lines:
if domainFull + '/users/' + moderator.strip('\n') + '/' in postId: if domain_full + '/users/' + moderator.strip('\n') + '/' in postId:
return False return False
return True return True
@ -1140,8 +1140,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
matchStr = domainFull + '/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):
f = f.name f = f.name

12
pgp.py
View File

@ -480,17 +480,17 @@ def pgpPublicKeyUpload(base_dir: str, session,
PGPpubKey = test PGPpubKey = test
PGPpubKeyId = None PGPpubKeyId = None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if debug: if debug:
print('PGP test domain: ' + domainFull) print('PGP test domain: ' + domain_full)
handle = nickname + '@' + domainFull handle = nickname + '@' + domain_full
if debug: if debug:
print('Getting actor for ' + handle) print('Getting actor for ' + handle)
actorJson, asHeader = \ actorJson, asHeader = \
getActorJson(domainFull, handle, False, False, debug, True, getActorJson(domain_full, handle, False, False, debug, True,
signing_priv_key_pem, session) signing_priv_key_pem, session)
if not actorJson: if not actorJson:
if debug: if debug:
@ -500,7 +500,7 @@ def pgpPublicKeyUpload(base_dir: str, session,
if debug: if debug:
print('Actor for ' + handle + ' obtained') print('Actor for ' + handle + ' obtained')
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
handle = replaceUsersWithAt(actor) handle = replaceUsersWithAt(actor)
# check that this looks like the correct actor # check that this looks like the correct actor
@ -601,7 +601,7 @@ def pgpPublicKeyUpload(base_dir: str, session,
tries = 0 tries = 0
while tries < 4: while tries < 4:
postResult = \ postResult = \
postJson(http_prefix, domainFull, postJson(http_prefix, domain_full,
session, actorUpdate, [], inboxUrl, session, actorUpdate, [], inboxUrl,
headers, 5, quiet) headers, 5, quiet)
if postResult: if postResult:

View File

@ -1151,9 +1151,9 @@ 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
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
idStr = \ idStr = \
localActorUrl(http_prefix, nickname, domainFull) + \ localActorUrl(http_prefix, nickname, domain_full) + \
'/statuses/' + statusNumber + '/replies' '/statuses/' + statusNumber + '/replies'
newPostUrl = \ newPostUrl = \
http_prefix + '://' + domain + '/@' + nickname + '/' + statusNumber http_prefix + '://' + domain + '/@' + nickname + '/' + statusNumber
@ -1168,7 +1168,7 @@ def _createPostC2S(base_dir: str, nickname: str, domain: str, port: int,
'inReplyTo': inReplyTo, 'inReplyTo': inReplyTo,
'published': published, 'published': published,
'url': newPostUrl, 'url': newPostUrl,
'attributedTo': localActorUrl(http_prefix, nickname, domainFull), 'attributedTo': localActorUrl(http_prefix, nickname, domain_full),
'to': toRecipients, 'to': toRecipients,
'cc': toCC, 'cc': toCC,
'sensitive': sensitive, 'sensitive': sensitive,
@ -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
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if not post_json_object.get('object'): if not post_json_object.get('object'):
return False return False
@ -1623,7 +1623,7 @@ def _postIsAddressedToFollowers(base_dir: str,
ccList = post_json_object['cc'] ccList = post_json_object['cc']
followersUrl = \ followersUrl = \
localActorUrl(http_prefix, nickname, domainFull) + '/followers' localActorUrl(http_prefix, nickname, domain_full) + '/followers'
# does the followers url exist in 'to' or 'cc' lists? # does the followers url exist in 'to' or 'cc' lists?
addressedToFollowers = False addressedToFollowers = False
@ -1661,13 +1661,13 @@ def undoPinnedPost(base_dir: str, nickname: str, domain: str) -> None:
def getPinnedPostAsJson(base_dir: str, http_prefix: str, def getPinnedPostAsJson(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, system_language: str) -> {}: domain_full: str, system_language: str) -> {}:
"""Returns the pinned profile post as json """Returns the pinned profile post as json
""" """
accountDir = acctDir(base_dir, nickname, domain) accountDir = acctDir(base_dir, nickname, domain)
pinnedFilename = accountDir + '/pinToProfile.txt' pinnedFilename = accountDir + '/pinToProfile.txt'
pinnedPostJson = {} pinnedPostJson = {}
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
if os.path.isfile(pinnedFilename): if os.path.isfile(pinnedFilename):
pinnedContent = None pinnedContent = None
with open(pinnedFilename, 'r') as pinFile: with open(pinnedFilename, 'r') as pinFile:
@ -1701,18 +1701,18 @@ def getPinnedPostAsJson(base_dir: str, http_prefix: str,
def jsonPinPost(base_dir: str, http_prefix: str, def jsonPinPost(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, system_language: str) -> {}: domain_full: str, system_language: str) -> {}:
"""Returns a pinned post as json """Returns a pinned post as json
""" """
pinnedPostJson = \ pinnedPostJson = \
getPinnedPostAsJson(base_dir, http_prefix, getPinnedPostAsJson(base_dir, http_prefix,
nickname, domain, nickname, domain,
domainFull, system_language) domain_full, system_language)
itemsList = [] itemsList = []
if pinnedPostJson: if pinnedPostJson:
itemsList = [pinnedPostJson] itemsList = [pinnedPostJson]
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
postContext = getIndividualPostContext() postContext = getIndividualPostContext()
return { return {
'@context': postContext, '@context': postContext,
@ -1771,7 +1771,7 @@ def createPublicPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Public post """Public post
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
isModerationReport = False isModerationReport = False
eventUUID = None eventUUID = None
category = None category = None
@ -1783,7 +1783,7 @@ def createPublicPost(base_dir: str,
anonymousParticipationEnabled = None anonymousParticipationEnabled = None
eventStatus = None eventStatus = None
ticketUrl = None ticketUrl = None
localActor = localActorUrl(http_prefix, nickname, domainFull) localActor = localActorUrl(http_prefix, nickname, domain_full)
return _createPostBase(base_dir, nickname, domain, port, return _createPostBase(base_dir, nickname, domain, port,
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
localActor + '/followers', localActor + '/followers',
@ -1907,8 +1907,8 @@ 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
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
localActor = localActorUrl(http_prefix, nickname, domainFull) localActor = localActorUrl(http_prefix, nickname, domain_full)
message_json = \ message_json = \
_createPostBase(base_dir, nickname, domain, port, _createPostBase(base_dir, nickname, domain, port,
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
@ -1957,8 +1957,8 @@ 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.
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
localActor = localActorUrl(http_prefix, nickname, domainFull) localActor = localActorUrl(http_prefix, nickname, domain_full)
return _createPostBase(base_dir, nickname, domain, port, return _createPostBase(base_dir, nickname, domain, port,
localActor + '/followers', localActor + '/followers',
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
@ -1992,8 +1992,8 @@ def createFollowersOnlyPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Followers only post """Followers only post
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
localActor = localActorUrl(http_prefix, nickname, domainFull) localActor = localActorUrl(http_prefix, nickname, domain_full)
return _createPostBase(base_dir, nickname, domain, port, return _createPostBase(base_dir, nickname, domain, port,
localActor + '/followers', localActor + '/followers',
None, None,
@ -2109,7 +2109,7 @@ def createReportPost(base_dir: str,
content_license_url: str) -> {}: content_license_url: str) -> {}:
"""Send a report to moderators """Send a report to moderators
""" """
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(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'
@ -2135,26 +2135,26 @@ def createReportPost(base_dir: str,
if '@' in line: if '@' in line:
nick = line.split('@')[0] nick = line.split('@')[0]
moderatorActor = \ moderatorActor = \
localActorUrl(http_prefix, nick, domainFull) localActorUrl(http_prefix, nick, domain_full)
if moderatorActor not in moderatorsList: if moderatorActor not in moderatorsList:
moderatorsList.append(moderatorActor) moderatorsList.append(moderatorActor)
continue continue
if line.startswith('http') or line.startswith('hyper'): if line.startswith('http') or line.startswith('hyper'):
# must be a local address - no remote moderators # must be a local address - no remote moderators
if '://' + domainFull + '/' in line: if '://' + domain_full + '/' in line:
if line not in moderatorsList: if line not in moderatorsList:
moderatorsList.append(line) moderatorsList.append(line)
else: else:
if '/' not in line: if '/' not in line:
moderatorActor = \ moderatorActor = \
localActorUrl(http_prefix, line, domainFull) localActorUrl(http_prefix, line, domain_full)
if moderatorActor not in moderatorsList: if moderatorActor not in moderatorsList:
moderatorsList.append(moderatorActor) moderatorsList.append(moderatorActor)
if len(moderatorsList) == 0: if len(moderatorsList) == 0:
# if there are no moderators then the admin becomes the moderator # if there are no moderators then the admin becomes the moderator
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
if adminNickname: if adminNickname:
localActor = localActorUrl(http_prefix, adminNickname, domainFull) localActor = localActorUrl(http_prefix, adminNickname, domain_full)
moderatorsList.append(localActor) moderatorsList.append(localActor)
if not moderatorsList: if not moderatorsList:
return None return None
@ -2378,15 +2378,15 @@ 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:
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if sharedItemFederationTokens.get(domainFull): if sharedItemFederationTokens.get(domain_full):
signatureHeaderJson['Origin'] = domainFull signatureHeaderJson['Origin'] = domain_full
signatureHeaderJson['SharesCatalog'] = \ signatureHeaderJson['SharesCatalog'] = \
sharedItemFederationTokens[domainFull] sharedItemFederationTokens[domain_full]
if debug: if debug:
print('SharesCatalog added to header') print('SharesCatalog added to header')
elif debug: elif debug:
print(domainFull + ' not in sharedItemFederationTokens') print(domain_full + ' not in sharedItemFederationTokens')
elif debug: elif debug:
print(toDomain + ' not in shared_items_federated_domains ' + print(toDomain + ' not in shared_items_federated_domains ' +
str(shared_items_federated_domains)) str(shared_items_federated_domains))
@ -2958,18 +2958,18 @@ 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:
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
toDomainFull = getFullDomain(toDomain, toPort) toDomainFull = getFullDomain(toDomain, toPort)
if nickname == toNickname and \ if nickname == toNickname and \
domainFull == toDomainFull: domain_full == toDomainFull:
if debug: if debug:
print('Not sending profile update to self. ' + print('Not sending profile update to self. ' +
nickname + '@' + domainFull) nickname + '@' + domain_full)
continue continue
if debug: if debug:
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
toDomainFull = getFullDomain(toDomain, toPort) toDomainFull = getFullDomain(toDomain, toPort)
print('DEBUG: Post sending s2s: ' + nickname + '@' + domainFull + print('DEBUG: Post sending s2s: ' + nickname + '@' + domain_full +
' to ' + toNickname + '@' + toDomainFull) ' to ' + toNickname + '@' + toDomainFull)
# if we have an alt onion domain and we are sending to # if we have an alt onion domain and we are sending to
@ -3142,9 +3142,9 @@ 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:
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
if sharedItemFederationTokens.get(domainFull): if sharedItemFederationTokens.get(domain_full):
sharedItemsToken = sharedItemFederationTokens[domainFull] sharedItemsToken = sharedItemFederationTokens[domain_full]
# check that the follower's domain is active # check that the follower's domain is active
followerDomainUrl = http_prefix + '://' + followerDomain followerDomainUrl = http_prefix + '://' + followerDomain
@ -3462,7 +3462,7 @@ def isImageMedia(session, base_dir: str, http_prefix: str,
allow_local_network_access: bool, allow_local_network_access: bool,
recentPostsCache: {}, debug: bool, recentPostsCache: {}, debug: bool,
system_language: str, system_language: str,
domainFull: str, person_cache: {}, domain_full: str, person_cache: {},
signing_priv_key_pem: str) -> bool: signing_priv_key_pem: str) -> bool:
"""Returns true if the given post has attached image media """Returns true if the given post has attached image media
""" """
@ -3477,7 +3477,7 @@ def isImageMedia(session, base_dir: str, http_prefix: str,
allow_local_network_access, allow_local_network_access,
recentPostsCache, debug, recentPostsCache, debug,
system_language, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
if postJsonAnnounce: if postJsonAnnounce:
@ -4086,8 +4086,8 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
handle = http_prefix + "://" + domainFull + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers, webfingerHandle(session, handle, http_prefix, cached_webfingers,
@ -4144,8 +4144,8 @@ def getPublicPostDomains(session, base_dir: str, nickname: str, domain: str,
cached_webfingers = {} cached_webfingers = {}
federation_list = [] federation_list = []
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
handle = http_prefix + "://" + domainFull + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers, webfingerHandle(session, handle, http_prefix, cached_webfingers,
domain, project_version, debug, False, domain, project_version, debug, False,
@ -4240,8 +4240,8 @@ def getPublicPostInfo(session, base_dir: str, nickname: str, domain: str,
cached_webfingers = {} cached_webfingers = {}
federation_list = [] federation_list = []
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
handle = http_prefix + "://" + domainFull + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, cached_webfingers, webfingerHandle(session, handle, http_prefix, cached_webfingers,
domain, project_version, debug, False, domain, project_version, debug, False,
@ -4515,7 +4515,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
allow_local_network_access: bool, allow_local_network_access: bool,
recentPostsCache: {}, debug: bool, recentPostsCache: {}, debug: bool,
system_language: str, system_language: str,
domainFull: str, person_cache: {}, domain_full: str, person_cache: {},
signing_priv_key_pem: str, signing_priv_key_pem: str,
blockedCache: {}) -> {}: blockedCache: {}) -> {}:
"""Download the post referenced by an announce """Download the post referenced by an announce
@ -4664,7 +4664,7 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
return None return None
if not understoodPostLanguage(base_dir, nickname, domain, if not understoodPostLanguage(base_dir, nickname, domain,
announcedJson, system_language, announcedJson, system_language,
http_prefix, domainFull, http_prefix, domain_full,
person_cache): person_cache):
return None return None
# Check the content of the announce # Check the content of the announce
@ -5137,8 +5137,8 @@ def c2sBoxJson(base_dir: str, session,
print('WARN: No session for c2sBoxJson') print('WARN: No session for c2sBoxJson')
return None return None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
authHeader = createBasicAuthHeader(nickname, password) authHeader = createBasicAuthHeader(nickname, password)

View File

@ -99,7 +99,7 @@ def _updatePostSchedule(base_dir: str, handle: str, httpd,
httpd, base_dir, httpd, base_dir,
httpd.http_prefix, httpd.http_prefix,
httpd.domain, httpd.domain,
httpd.domainFull, httpd.domain_full,
httpd.onion_domain, httpd.onion_domain,
httpd.i2p_domain, httpd.i2p_domain,
httpd.port, httpd.port,

View File

@ -86,7 +86,7 @@ def urlExists(session, url: str, timeoutSec: int = 3,
return False return False
def _getJsonRequest(session, url: str, domainFull: str, sessionHeaders: {}, def _getJsonRequest(session, url: str, domain_full: str, sessionHeaders: {},
sessionParams: {}, timeoutSec: int, sessionParams: {}, timeoutSec: int,
signing_priv_key_pem: str, quiet: bool, debug: bool, signing_priv_key_pem: str, quiet: bool, debug: bool,
returnJson: bool) -> {}: returnJson: bool) -> {}:
@ -136,12 +136,12 @@ def _getJsonRequest(session, url: str, domainFull: str, sessionHeaders: {},
return None return None
def _getJsonSigned(session, url: str, domainFull: str, sessionHeaders: {}, def _getJsonSigned(session, url: str, domain_full: str, sessionHeaders: {},
sessionParams: {}, timeoutSec: int, sessionParams: {}, timeoutSec: int,
signing_priv_key_pem: str, quiet: bool, debug: bool) -> {}: signing_priv_key_pem: str, quiet: bool, debug: bool) -> {}:
"""Authorized fetch - a signed version of GET """Authorized fetch - a signed version of GET
""" """
if not domainFull: if not domain_full:
if debug: if debug:
print('No sending domain for signed GET') print('No sending domain for signed GET')
return None return None
@ -153,11 +153,11 @@ def _getJsonSigned(session, url: str, domainFull: str, sessionHeaders: {},
if '/' in toDomainFull: if '/' in toDomainFull:
toDomainFull = toDomainFull.split('/')[0] toDomainFull = toDomainFull.split('/')[0]
if ':' in domainFull: if ':' in domain_full:
domain = domainFull.split(':')[0] domain = domain_full.split(':')[0]
port = domainFull.split(':')[1] port = domain_full.split(':')[1]
else: else:
domain = domainFull domain = domain_full
if http_prefix == 'https': if http_prefix == 'https':
port = 443 port = 443
else: else:
@ -205,7 +205,7 @@ def _getJsonSigned(session, url: str, domainFull: str, sessionHeaders: {},
returnJson = True returnJson = True
if 'json' not in contentType: if 'json' not in contentType:
returnJson = False returnJson = False
return _getJsonRequest(session, url, domainFull, sessionHeaders, return _getJsonRequest(session, url, domain_full, sessionHeaders,
sessionParams, timeoutSec, None, quiet, sessionParams, timeoutSec, None, quiet,
debug, returnJson) debug, returnJson)
@ -290,7 +290,7 @@ def downloadHtml(signing_priv_key_pem: str,
None, quiet, debug, False) None, quiet, debug, False)
def postJson(http_prefix: str, domainFull: str, def postJson(http_prefix: str, domain_full: str,
session, post_json_object: {}, federation_list: [], session, post_json_object: {}, federation_list: [],
inboxUrl: str, headers: {}, timeoutSec: int = 60, inboxUrl: str, headers: {}, timeoutSec: int = 60,
quiet: bool = False) -> str: quiet: bool = False) -> str:
@ -305,7 +305,7 @@ def postJson(http_prefix: str, domainFull: str,
sessionHeaders = headers sessionHeaders = headers
sessionHeaders['User-Agent'] = 'Epicyon/' + __version__ sessionHeaders['User-Agent'] = 'Epicyon/' + __version__
sessionHeaders['User-Agent'] += \ sessionHeaders['User-Agent'] += \
'; +' + http_prefix + '://' + domainFull + '/' '; +' + http_prefix + '://' + domain_full + '/'
try: try:
postResult = \ postResult = \

View File

@ -48,7 +48,7 @@ from blocking import isBlocked
def _loadDfcIds(base_dir: str, system_language: str, def _loadDfcIds(base_dir: str, system_language: str,
productType: str, productType: str,
http_prefix: str, domainFull: str) -> {}: http_prefix: str, domain_full: str) -> {}:
"""Loads the product types ontology """Loads the product types ontology
This is used to add an id to shared items This is used to add an id to shared items
""" """
@ -95,7 +95,7 @@ def _loadDfcIds(base_dir: str, system_language: str,
if label['@language'] == system_language: if label['@language'] == system_language:
itemId = \ itemId = \
item['@id'].replace('http://static.datafoodconsortium.org', item['@id'].replace('http://static.datafoodconsortium.org',
http_prefix + '://' + domainFull) http_prefix + '://' + domain_full)
dfcIds[label['@value'].lower()] = itemId dfcIds[label['@value'].lower()] = itemId
break break
return dfcIds return dfcIds
@ -120,7 +120,7 @@ def _getValidSharedItemID(actor: str, displayName: str) -> str:
def removeSharedItem(base_dir: str, nickname: str, domain: str, def removeSharedItem(base_dir: str, nickname: str, domain: str,
itemID: str, itemID: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
sharesFileType: str) -> None: sharesFileType: str) -> None:
"""Removes a share for a person """Removes a share for a person
""" """
@ -202,7 +202,7 @@ def _dfcProductTypeFromCategory(base_dir: str,
def _getshareDfcId(base_dir: str, system_language: str, def _getshareDfcId(base_dir: str, system_language: str,
itemType: str, itemCategory: str, itemType: str, itemCategory: str,
translate: {}, translate: {},
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
dfcIds: {} = None) -> str: dfcIds: {} = None) -> str:
"""Attempts to obtain a DFC Id for the shared item, """Attempts to obtain a DFC Id for the shared item,
based upon productTypes ontology. based upon productTypes ontology.
@ -218,7 +218,7 @@ def _getshareDfcId(base_dir: str, system_language: str,
return 'epicyon#' + itemType return 'epicyon#' + itemType
if not dfcIds: if not dfcIds:
dfcIds = _loadDfcIds(base_dir, system_language, matchedProductType, dfcIds = _loadDfcIds(base_dir, system_language, matchedProductType,
http_prefix, domainFull) http_prefix, domain_full)
if not dfcIds: if not dfcIds:
return '' return ''
itemTypeLower = itemType.lower() itemTypeLower = itemType.lower()
@ -266,7 +266,7 @@ def _getshareTypeFromDfcId(dfcUri: str, dfcIds: {}) -> str:
def _indicateNewShareAvailable(base_dir: str, http_prefix: str, def _indicateNewShareAvailable(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, sharesFileType: str) -> None: domain_full: str, sharesFileType: str) -> None:
"""Indicate to each account that a new share is available """Indicate to each account that a new share is available
""" """
for subdir, dirs, files in os.walk(base_dir + '/accounts'): for subdir, dirs, files in os.walk(base_dir + '/accounts'):
@ -287,7 +287,7 @@ def _indicateNewShareAvailable(base_dir: str, http_prefix: str,
nickname, domain, None): nickname, domain, None):
continue continue
localActor = \ localActor = \
localActorUrl(http_prefix, accountNickname, domainFull) localActorUrl(http_prefix, accountNickname, domain_full)
try: try:
with open(newShareFile, 'w+') as fp: with open(newShareFile, 'w+') as fp:
if sharesFileType == 'shares': if sharesFileType == 'shares':
@ -326,12 +326,12 @@ def addShare(base_dir: str,
published = int(time.time()) published = int(time.time())
durationSec = _addShareDurationSec(duration, published) durationSec = _addShareDurationSec(duration, published)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(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,
itemType, itemCategory, translate, itemType, itemCategory, translate,
http_prefix, domainFull) http_prefix, domain_full)
# has an image for this share been uploaded? # has an image for this share been uploaded?
imageUrl = None imageUrl = None
@ -345,7 +345,7 @@ def addShare(base_dir: str,
imageFilename = sharesImageFilename + '.' + ext imageFilename = sharesImageFilename + '.' + ext
moveImage = True moveImage = True
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(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:
@ -371,7 +371,7 @@ def addShare(base_dir: str,
print('EX: addShare unable to delete ' + print('EX: addShare unable to delete ' +
str(imageFilename)) str(imageFilename))
imageUrl = \ imageUrl = \
http_prefix + '://' + domainFull + \ http_prefix + '://' + domain_full + \
'/sharefiles/' + nickname + '/' + itemID + '.' + ext '/sharefiles/' + nickname + '/' + itemID + '.' + ext
sharesJson[itemID] = { sharesJson[itemID] = {
@ -392,7 +392,7 @@ def addShare(base_dir: str,
saveJson(sharesJson, sharesFilename) saveJson(sharesJson, sharesFilename)
_indicateNewShareAvailable(base_dir, http_prefix, _indicateNewShareAvailable(base_dir, http_prefix,
nickname, domain, domainFull, nickname, domain, domain_full,
sharesFileType) sharesFileType)
@ -1010,8 +1010,8 @@ def getSharedItemsCatalogViaServer(base_dir, session,
'Authorization': authHeader, 'Authorization': authHeader,
'Accept': 'application/json' 'Accept': 'application/json'
} }
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
url = localActorUrl(http_prefix, nickname, domainFull) + '/catalog' url = localActorUrl(http_prefix, nickname, domain_full) + '/catalog'
if debug: if debug:
print('Shared items catalog request to: ' + url) print('Shared items catalog request to: ' + url)
catalogJson = getJson(signing_priv_key_pem, session, url, headers, None, catalogJson = getJson(signing_priv_key_pem, session, url, headers, None,
@ -1118,10 +1118,10 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
removeSharedItem(base_dir, nickname, domain, removeSharedItem(base_dir, nickname, domain,
message_json['object']['displayName'], message_json['object']['displayName'],
http_prefix, domainFull, 'shares') http_prefix, domain_full, 'shares')
if debug: if debug:
print('DEBUG: shared item removed via c2s') print('DEBUG: shared item removed via c2s')
@ -1159,7 +1159,7 @@ def _sharesCatalogParams(path: str) -> (bool, float, float, str):
def sharesCatalogAccountEndpoint(base_dir: str, http_prefix: str, def sharesCatalogAccountEndpoint(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, domain_full: str,
path: str, debug: bool, path: str, debug: bool,
sharesFileType: str) -> {}: sharesFileType: str) -> {}:
"""Returns the endpoint for the shares catalog of a particular account """Returns the endpoint for the shares catalog of a particular account
@ -1168,11 +1168,11 @@ def sharesCatalogAccountEndpoint(base_dir: str, http_prefix: str,
""" """
today, minPrice, maxPrice, matchPattern = _sharesCatalogParams(path) today, minPrice, maxPrice, matchPattern = _sharesCatalogParams(path)
dfcUrl = \ dfcUrl = \
http_prefix + '://' + domainFull + '/ontologies/DFC_FullModel.owl#' http_prefix + '://' + domain_full + '/ontologies/DFC_FullModel.owl#'
dfcPtUrl = \ dfcPtUrl = \
http_prefix + '://' + domainFull + \ http_prefix + '://' + domain_full + \
'/ontologies/DFC_ProductGlossary.rdf#' '/ontologies/DFC_ProductGlossary.rdf#'
owner = localActorUrl(http_prefix, nickname, domainFull) owner = localActorUrl(http_prefix, nickname, domain_full)
if sharesFileType == 'shares': if sharesFileType == 'shares':
dfcInstanceId = owner + '/catalog' dfcInstanceId = owner + '/catalog'
else: else:
@ -1250,7 +1250,7 @@ def sharesCatalogAccountEndpoint(base_dir: str, http_prefix: str,
def sharesCatalogEndpoint(base_dir: str, http_prefix: str, def sharesCatalogEndpoint(base_dir: str, http_prefix: str,
domainFull: str, domain_full: str,
path: str, sharesFileType: str) -> {}: path: str, sharesFileType: str) -> {}:
"""Returns the endpoint for the shares catalog for the instance """Returns the endpoint for the shares catalog for the instance
See https://github.com/datafoodconsortium/ontology See https://github.com/datafoodconsortium/ontology
@ -1258,11 +1258,11 @@ def sharesCatalogEndpoint(base_dir: str, http_prefix: str,
""" """
today, minPrice, maxPrice, matchPattern = _sharesCatalogParams(path) today, minPrice, maxPrice, matchPattern = _sharesCatalogParams(path)
dfcUrl = \ dfcUrl = \
http_prefix + '://' + domainFull + '/ontologies/DFC_FullModel.owl#' http_prefix + '://' + domain_full + '/ontologies/DFC_FullModel.owl#'
dfcPtUrl = \ dfcPtUrl = \
http_prefix + '://' + domainFull + \ http_prefix + '://' + domain_full + \
'/ontologies/DFC_ProductGlossary.rdf#' '/ontologies/DFC_ProductGlossary.rdf#'
dfcInstanceId = http_prefix + '://' + domainFull + '/catalog' dfcInstanceId = http_prefix + '://' + domain_full + '/catalog'
endpoint = { endpoint = {
"@context": { "@context": {
"DFC": dfcUrl, "DFC": dfcUrl,
@ -1283,7 +1283,7 @@ def sharesCatalogEndpoint(base_dir: str, http_prefix: str,
continue continue
nickname = acct.split('@')[0] nickname = acct.split('@')[0]
domain = acct.split('@')[1] domain = acct.split('@')[1]
owner = localActorUrl(http_prefix, nickname, domainFull) owner = localActorUrl(http_prefix, nickname, domain_full)
sharesFilename = \ sharesFilename = \
acctDir(base_dir, nickname, domain) + '/' + \ acctDir(base_dir, nickname, domain) + '/' + \
@ -1339,12 +1339,12 @@ def sharesCatalogEndpoint(base_dir: str, http_prefix: str,
def sharesCatalogCSVEndpoint(base_dir: str, http_prefix: str, def sharesCatalogCSVEndpoint(base_dir: str, http_prefix: str,
domainFull: str, domain_full: str,
path: str, sharesFileType: str) -> str: path: str, sharesFileType: str) -> str:
"""Returns a CSV version of the shares catalog """Returns a CSV version of the shares catalog
""" """
catalogJson = \ catalogJson = \
sharesCatalogEndpoint(base_dir, http_prefix, domainFull, path, sharesCatalogEndpoint(base_dir, http_prefix, domain_full, path,
sharesFileType) sharesFileType)
if not catalogJson: if not catalogJson:
return '' return ''
@ -1386,9 +1386,9 @@ def generateSharedItemFederationTokens(shared_items_federated_domains: [],
tokensJson = {} tokensJson = {}
tokensAdded = False tokensAdded = False
for domainFull in shared_items_federated_domains: for domain_full in shared_items_federated_domains:
if not tokensJson.get(domainFull): if not tokensJson.get(domain_full):
tokensJson[domainFull] = '' tokensJson[domain_full] = ''
tokensAdded = True tokensAdded = True
if not tokensAdded: if not tokensAdded:
@ -1430,7 +1430,7 @@ def updateSharedItemFederationToken(base_dir: str,
return tokensJson return tokensJson
def mergeSharedItemTokens(base_dir: str, domainFull: str, def mergeSharedItemTokens(base_dir: str, domain_full: str,
newSharedItemsFederatedDomains: [], newSharedItemsFederatedDomains: [],
tokensJson: {}) -> {}: tokensJson: {}) -> {}:
"""When the shared item federation domains list has changed, update """When the shared item federation domains list has changed, update
@ -1439,8 +1439,8 @@ def mergeSharedItemTokens(base_dir: str, domainFull: str,
removals = [] removals = []
changed = False changed = False
for tokenDomainFull, tok in tokensJson.items(): for tokenDomainFull, tok in tokensJson.items():
if domainFull: if domain_full:
if tokenDomainFull.startswith(domainFull): if tokenDomainFull.startswith(domain_full):
continue continue
if tokenDomainFull not in newSharedItemsFederatedDomains: if tokenDomainFull not in newSharedItemsFederatedDomains:
removals.append(tokenDomainFull) removals.append(tokenDomainFull)
@ -1540,7 +1540,7 @@ def authorizeSharedItems(shared_items_federated_domains: [],
def _updateFederatedSharesCache(session, shared_items_federated_domains: [], def _updateFederatedSharesCache(session, shared_items_federated_domains: [],
base_dir: str, domainFull: str, base_dir: str, domain_full: str,
http_prefix: str, http_prefix: str,
tokensJson: {}, debug: bool, tokensJson: {}, debug: bool,
system_language: str, system_language: str,
@ -1562,12 +1562,12 @@ def _updateFederatedSharesCache(session, shared_items_federated_domains: [],
asHeader = { asHeader = {
"Accept": "application/ld+json", "Accept": "application/ld+json",
"Origin": domainFull "Origin": domain_full
} }
for federatedDomainFull in shared_items_federated_domains: for federatedDomainFull in shared_items_federated_domains:
# NOTE: federatedDomain does not have a port extension, # NOTE: federatedDomain does not have a port extension,
# so may not work in some situations # so may not work in some situations
if federatedDomainFull.startswith(domainFull): if federatedDomainFull.startswith(domain_full):
# only download from instances other than this one # only download from instances other than this one
continue continue
if not tokensJson.get(federatedDomainFull): if not tokensJson.get(federatedDomainFull):
@ -1591,7 +1591,7 @@ def _updateFederatedSharesCache(session, shared_items_federated_domains: [],
print('Downloaded shared items catalog for ' + federatedDomainFull) print('Downloaded shared items catalog for ' + federatedDomainFull)
sharesJson = _dfcToSharesFormat(catalogJson, sharesJson = _dfcToSharesFormat(catalogJson,
base_dir, system_language, base_dir, system_language,
http_prefix, domainFull) http_prefix, domain_full)
if sharesJson: if sharesJson:
sharesFilename = \ sharesFilename = \
catalogsDir + '/' + federatedDomainFull + '.' + \ catalogsDir + '/' + federatedDomainFull + '.' + \
@ -1657,7 +1657,7 @@ def _generateNextSharesTokenUpdate(base_dir: str,
fp.write(str(nextUpdateSec)) fp.write(str(nextUpdateSec))
def _regenerateSharesToken(base_dir: str, domainFull: str, def _regenerateSharesToken(base_dir: str, domain_full: str,
minDays: int, maxDays: int, httpd) -> None: minDays: int, maxDays: int, httpd) -> None:
"""Occasionally the shared items token for your instance is updated. """Occasionally the shared items token for your instance is updated.
Scenario: Scenario:
@ -1688,7 +1688,7 @@ def _regenerateSharesToken(base_dir: str, domainFull: str,
currTime = int(time.time()) currTime = int(time.time())
if currTime <= nextUpdateSec: if currTime <= nextUpdateSec:
return return
createSharedItemFederationToken(base_dir, domainFull, True, None) createSharedItemFederationToken(base_dir, domain_full, True, None)
_generateNextSharesTokenUpdate(base_dir, minDays, maxDays) _generateNextSharesTokenUpdate(base_dir, minDays, maxDays)
# update the tokens used within the daemon # update the tokens used within the daemon
shared_fed_domains = httpd.shared_items_federated_domains shared_fed_domains = httpd.shared_items_federated_domains
@ -1698,7 +1698,7 @@ def _regenerateSharesToken(base_dir: str, domainFull: str,
def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str, def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
domainFull: str, proxy_type: str, debug: bool, domain_full: str, proxy_type: str, debug: bool,
system_language: str) -> None: system_language: str) -> None:
"""Runs the daemon used to update federated shared items """Runs the daemon used to update federated shared items
""" """
@ -1718,7 +1718,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
# occasionally change the federated shared items token # occasionally change the federated shared items token
# for this instance # for this instance
_regenerateSharesToken(base_dir, domainFull, minDays, maxDays, httpd) _regenerateSharesToken(base_dir, domain_full, minDays, maxDays, httpd)
# get a list of the domains within the shared items federation # get a list of the domains within the shared items federation
shared_items_federated_domains = [] shared_items_federated_domains = []
@ -1745,7 +1745,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
for sharesFileType in getSharesFilesList(): for sharesFileType in getSharesFilesList():
_updateFederatedSharesCache(session, _updateFederatedSharesCache(session,
shared_items_federated_domains, shared_items_federated_domains,
base_dir, domainFull, http_prefix, base_dir, domain_full, http_prefix,
tokensJson, debug, system_language, tokensJson, debug, system_language,
sharesFileType) sharesFileType)
time.sleep(secondsPerHour * 6) time.sleep(secondsPerHour * 6)
@ -1753,7 +1753,7 @@ def runFederatedSharesDaemon(base_dir: str, httpd, http_prefix: str,
def _dfcToSharesFormat(catalogJson: {}, def _dfcToSharesFormat(catalogJson: {},
base_dir: str, system_language: str, base_dir: str, system_language: str,
http_prefix: str, domainFull: str) -> {}: http_prefix: str, domain_full: str) -> {}:
"""Converts DFC format into the internal formal used to store shared items. """Converts DFC format into the internal formal used to store shared items.
This simplifies subsequent search and display This simplifies subsequent search and display
""" """
@ -1766,7 +1766,7 @@ def _dfcToSharesFormat(catalogJson: {},
for productType in productTypesList: for productType in productTypesList:
dfcIds[productType] = \ dfcIds[productType] = \
_loadDfcIds(base_dir, system_language, productType, _loadDfcIds(base_dir, system_language, productType,
http_prefix, domainFull) http_prefix, domain_full)
currTime = int(time.time()) currTime = int(time.time())
for item in catalogJson['DFC:supplies']: for item in catalogJson['DFC:supplies']:

View File

@ -185,9 +185,9 @@ 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
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
toUrl = actor toUrl = actor
ccUrl = actor + '/followers' ccUrl = actor + '/followers'
@ -204,7 +204,7 @@ def sendSkillViaServer(base_dir: str, session, nickname: str, password: str,
'cc': [ccUrl] 'cc': [ccUrl]
} }
handle = http_prefix + '://' + domainFull + '/@' + nickname handle = http_prefix + '://' + domain_full + '/@' + nickname
# lookup the inbox for the To handle # lookup the inbox for the To handle
wfRequest = \ wfRequest = \
@ -251,7 +251,7 @@ def sendSkillViaServer(base_dir: str, session, nickname: str, password: str,
'Authorization': authHeader 'Authorization': authHeader
} }
postResult = \ postResult = \
postJson(http_prefix, domainFull, postJson(http_prefix, domain_full,
session, newSkillJson, [], inboxUrl, session, newSkillJson, [], inboxUrl,
headers, 30, True) headers, 30, True)
if not postResult: if not postResult:

View File

@ -49,8 +49,8 @@ def instancesGraph(base_dir: str, handles: str,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
domain = handle.split('@')[1] domain = handle.split('@')[1]
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
handle = http_prefix + "://" + domainFull + "/@" + nickname handle = http_prefix + "://" + domain_full + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, http_prefix, webfingerHandle(session, handle, http_prefix,
cached_webfingers, cached_webfingers,

View File

@ -196,21 +196,21 @@ def speakerReplaceLinks(sayText: str, translate: {},
prevWord = word prevWord = word
domain = None domain = None
domainFull = None domain_full = None
if 'https://' in word: if 'https://' in word:
domain = word.split('https://')[1] domain = word.split('https://')[1]
domainFull = 'https://' + domain domain_full = 'https://' + domain
elif 'http://' in word: elif 'http://' in word:
domain = word.split('http://')[1] domain = word.split('http://')[1]
domainFull = 'http://' + domain domain_full = 'http://' + domain
if not domain: if not domain:
continue continue
if '/' in domain: if '/' in domain:
domain = domain.split('/')[0] domain = domain.split('/')[0]
if domain.startswith('www.'): if domain.startswith('www.'):
domain = domain.replace('www.', '') domain = domain.replace('www.', '')
replacements[domainFull] = '. ' + linkedStr + ' ' + domain + '.' replacements[domain_full] = '. ' + linkedStr + ' ' + domain + '.'
detectedLinks.append(domainFull) detectedLinks.append(domain_full)
for replaceStr, newStr in replacements.items(): for replaceStr, newStr in replacements.items():
sayText = sayText.replace(replaceStr, newStr) sayText = sayText.replace(replaceStr, newStr)
return sayText.replace('..', '.') return sayText.replace('..', '.')
@ -403,7 +403,7 @@ def speakableText(base_dir: str, content: str, translate: {}) -> (str, []):
def _postToSpeakerJson(base_dir: str, http_prefix: str, def _postToSpeakerJson(base_dir: str, http_prefix: str,
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, person_cache: {}, post_json_object: {}, person_cache: {},
translate: {}, announcingActor: str, translate: {}, announcingActor: str,
theme_name: str) -> {}: theme_name: str) -> {}:
@ -454,7 +454,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
img['name'] + '. ' img['name'] + '. '
isDirect = isDM(post_json_object) isDirect = isDM(post_json_object)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
replyToYou = isReply(post_json_object, actor) replyToYou = isReply(post_json_object, actor)
published = '' published = ''
@ -495,7 +495,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
followRequestsExist = False followRequestsExist = False
followRequestsList = [] followRequestsList = []
accountsDir = acctDir(base_dir, nickname, domainFull) accountsDir = acctDir(base_dir, nickname, domain_full)
approveFollowsFilename = accountsDir + '/followrequests.txt' approveFollowsFilename = accountsDir + '/followrequests.txt'
if os.path.isfile(approveFollowsFilename): if os.path.isfile(approveFollowsFilename):
with open(approveFollowsFilename, 'r') as fp: with open(approveFollowsFilename, 'r') as fp:
@ -535,7 +535,7 @@ def _postToSpeakerJson(base_dir: str, http_prefix: str,
def updateSpeaker(base_dir: str, http_prefix: str, def updateSpeaker(base_dir: str, http_prefix: str,
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
post_json_object: {}, person_cache: {}, post_json_object: {}, person_cache: {},
translate: {}, announcingActor: str, translate: {}, announcingActor: str,
theme_name: str) -> None: theme_name: str) -> None:
@ -544,7 +544,7 @@ def updateSpeaker(base_dir: str, http_prefix: str,
""" """
speakerJson = \ speakerJson = \
_postToSpeakerJson(base_dir, http_prefix, _postToSpeakerJson(base_dir, http_prefix,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
translate, announcingActor, translate, announcingActor,
theme_name) theme_name)

View File

@ -778,7 +778,7 @@ def _setThemeImages(base_dir: str, name: str) -> None:
def setNewsAvatar(base_dir: str, name: str, def setNewsAvatar(base_dir: str, name: str,
http_prefix: str, http_prefix: str,
domain: str, domainFull: str) -> None: domain: str, domain_full: str) -> None:
"""Sets the avatar for the news account """Sets the avatar for the news account
""" """
nickname = 'news' nickname = 'news'
@ -788,7 +788,7 @@ def setNewsAvatar(base_dir: str, name: str,
if not os.path.isfile(newFilename): if not os.path.isfile(newFilename):
return return
avatarFilename = \ avatarFilename = \
localActorUrl(http_prefix, domainFull, nickname) + '.png' localActorUrl(http_prefix, domain_full, nickname) + '.png'
avatarFilename = avatarFilename.replace('/', '-') avatarFilename = avatarFilename.replace('/', '-')
filename = base_dir + '/cache/avatars/' + avatarFilename filename = base_dir + '/cache/avatars/' + avatarFilename

View File

@ -28,10 +28,10 @@ invalidCharacters = (
) )
def localActorUrl(http_prefix: str, nickname: str, domainFull: str) -> str: def localActorUrl(http_prefix: str, nickname: str, domain_full: str) -> str:
"""Returns the url for an actor on this instance """Returns the url for an actor on this instance
""" """
return http_prefix + '://' + domainFull + '/users/' + nickname return http_prefix + '://' + domain_full + '/users/' + nickname
def getActorLanguagesList(actorJson: {}) -> []: def getActorLanguagesList(actorJson: {}) -> []:
@ -2854,16 +2854,16 @@ def hasObjectDict(post_json_object: {}) -> bool:
return False return False
def getAltPath(actor: str, domainFull: str, callingDomain: str) -> str: def getAltPath(actor: str, domain_full: str, callingDomain: str) -> str:
"""Returns alternate path from the actor """Returns alternate path from the actor
eg. https://clearnetdomain/path becomes http://oniondomain/path eg. https://clearnetdomain/path becomes http://oniondomain/path
""" """
postActor = actor postActor = actor
if callingDomain not in actor and domainFull in actor: if callingDomain not in actor and domain_full in actor:
if callingDomain.endswith('.onion') or \ if callingDomain.endswith('.onion') or \
callingDomain.endswith('.i2p'): callingDomain.endswith('.i2p'):
postActor = \ postActor = \
'http://' + callingDomain + actor.split(domainFull)[1] 'http://' + callingDomain + actor.split(domain_full)[1]
print('Changed POST domain from ' + actor + ' to ' + postActor) print('Changed POST domain from ' + actor + ' to ' + postActor)
return postActor return postActor

View File

@ -16,7 +16,7 @@ from markdown import markdownToHtml
def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str, def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str,
domainFull: str, onion_domain: str, translate: {}, domain_full: str, onion_domain: str, translate: {},
system_language: str) -> str: system_language: str) -> str:
"""Show the about screen """Show the about screen
""" """
@ -44,7 +44,7 @@ def htmlAbout(cssCache: {}, base_dir: str, http_prefix: str,
getConfigParam(base_dir, 'instanceTitle') getConfigParam(base_dir, 'instanceTitle')
aboutForm = \ aboutForm = \
htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle, htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle,
http_prefix, domainFull, http_prefix, domain_full,
system_language) system_language)
aboutForm += '<div class="container">' + aboutText + '</div>' aboutForm += '<div class="container">' + aboutText + '</div>'
if onion_domain: if onion_domain:

View File

@ -33,13 +33,13 @@ from webapp_utils import htmlKeyboardNavigation
def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str, def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str,
path: str, http_prefix: str, path: str, http_prefix: str,
domainFull: str, postId: str, postTime: str, domain_full: str, postId: str, postTime: str,
year: int, monthNumber: int, year: int, monthNumber: int,
dayNumber: int, callingDomain: str) -> str: dayNumber: int, callingDomain: str) -> str:
"""Shows a screen asking to confirm the deletion of a calendar event """Shows a screen asking to confirm the deletion of a calendar event
""" """
nickname = getNicknameFromActor(path) nickname = getNicknameFromActor(path)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
messageId = actor + '/statuses/' + postId messageId = actor + '/statuses/' + postId
@ -68,7 +68,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, base_dir: str,
deletePostStr += ' <p class="followText">' + \ deletePostStr += ' <p class="followText">' + \
translate['Delete this event'] + '</p>' translate['Delete this event'] + '</p>'
postActor = getAltPath(actor, domainFull, callingDomain) postActor = getAltPath(actor, domain_full, callingDomain)
deletePostStr += \ deletePostStr += \
' <form method="POST" action="' + postActor + '/rmpost">\n' ' <form method="POST" action="' + postActor + '/rmpost">\n'
deletePostStr += ' <input type="hidden" name="year" value="' + \ deletePostStr += ' <input type="hidden" name="year" value="' + \
@ -245,16 +245,16 @@ def _htmlCalendarDay(person_cache: {}, cssCache: {}, translate: {},
def htmlCalendar(person_cache: {}, cssCache: {}, translate: {}, def htmlCalendar(person_cache: {}, cssCache: {}, translate: {},
base_dir: str, path: str, base_dir: str, path: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
text_mode_banner: str, accessKeys: {}) -> str: text_mode_banner: str, accessKeys: {}) -> str:
"""Show the calendar for a person """Show the calendar for a person
""" """
domain = removeDomainPort(domainFull) domain = removeDomainPort(domain_full)
monthNumber = 0 monthNumber = 0
dayNumber = None dayNumber = None
year = 1970 year = 1970
actor = http_prefix + '://' + domainFull + path.replace('/calendar', '') actor = http_prefix + '://' + domain_full + path.replace('/calendar', '')
if '?' in actor: if '?' in actor:
first = True first = True
for p in actor.split('?'): for p in actor.split('?'):

View File

@ -33,7 +33,7 @@ def _linksExist(base_dir: str) -> bool:
def _getLeftColumnShares(base_dir: str, def _getLeftColumnShares(base_dir: str,
http_prefix: str, domain: str, domainFull: str, http_prefix: str, domain: str, domain_full: str,
nickname: str, nickname: str,
maxSharesInLeftColumn: int, maxSharesInLeftColumn: int,
translate: {}, translate: {},
@ -41,7 +41,7 @@ def _getLeftColumnShares(base_dir: str,
"""get any shares and turn them into the left column links format """get any shares and turn them into the left column links format
""" """
pageNumber = 1 pageNumber = 1
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
# NOTE: this could potentially be slow if the number of federated # NOTE: this could potentially be slow if the number of federated
# shared items is large # shared items is large
sharesJson, lastPage = \ sharesJson, lastPage = \
@ -75,7 +75,7 @@ def _getLeftColumnShares(base_dir: str,
def _getLeftColumnWanted(base_dir: str, def _getLeftColumnWanted(base_dir: str,
http_prefix: str, domain: str, domainFull: str, http_prefix: str, domain: str, domain_full: str,
nickname: str, nickname: str,
maxSharesInLeftColumn: int, maxSharesInLeftColumn: int,
translate: {}, translate: {},
@ -83,7 +83,7 @@ def _getLeftColumnWanted(base_dir: str,
"""get any wanted items and turn them into the left column links format """get any wanted items and turn them into the left column links format
""" """
pageNumber = 1 pageNumber = 1
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
# NOTE: this could potentially be slow if the number of federated # NOTE: this could potentially be slow if the number of federated
# wanted items is large # wanted items is large
sharesJson, lastPage = \ sharesJson, lastPage = \
@ -112,7 +112,7 @@ def _getLeftColumnWanted(base_dir: str,
return linksList return linksList
def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str, def getLeftColumnContent(base_dir: str, nickname: str, domain_full: str,
http_prefix: str, translate: {}, http_prefix: str, translate: {},
editor: bool, artist: bool, editor: bool, artist: bool,
showBackButton: bool, timelinePath: str, showBackButton: bool, timelinePath: str,
@ -125,7 +125,7 @@ def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str,
htmlStr = '' htmlStr = ''
separatorStr = htmlPostSeparator(base_dir, 'left') separatorStr = htmlPostSeparator(base_dir, 'left')
domain = removeDomainPort(domainFull) domain = removeDomainPort(domain_full)
editImageClass = '' editImageClass = ''
if showHeaderImage: if showHeaderImage:
@ -177,11 +177,11 @@ def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str,
# RSS icon # RSS icon
if nickname != 'news': if nickname != 'news':
# rss feed for this account # rss feed for this account
rssUrl = http_prefix + '://' + domainFull + \ rssUrl = http_prefix + '://' + domain_full + \
'/blog/' + nickname + '/rss.xml' '/blog/' + nickname + '/rss.xml'
else: else:
# rss feed for all accounts on the instance # rss feed for all accounts on the instance
rssUrl = http_prefix + '://' + domainFull + '/blog/rss.xml' rssUrl = http_prefix + '://' + domain_full + '/blog/rss.xml'
if not frontPage: if not frontPage:
rssTitle = translate['RSS feed for your blog'] rssTitle = translate['RSS feed for your blog']
else: else:
@ -218,7 +218,7 @@ def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str,
maxSharesInLeftColumn = 3 maxSharesInLeftColumn = 3
sharesList = \ sharesList = \
_getLeftColumnShares(base_dir, _getLeftColumnShares(base_dir,
http_prefix, domain, domainFull, nickname, http_prefix, domain, domain_full, nickname,
maxSharesInLeftColumn, translate, maxSharesInLeftColumn, translate,
shared_items_federated_domains) shared_items_federated_domains)
if linksList and sharesList: if linksList and sharesList:
@ -226,7 +226,7 @@ def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str,
wantedList = \ wantedList = \
_getLeftColumnWanted(base_dir, _getLeftColumnWanted(base_dir,
http_prefix, domain, domainFull, nickname, http_prefix, domain, domain_full, nickname,
maxSharesInLeftColumn, translate, maxSharesInLeftColumn, translate,
shared_items_federated_domains) shared_items_federated_domains)
if linksList and wantedList: if linksList and wantedList:
@ -349,7 +349,7 @@ def getLeftColumnContent(base_dir: str, nickname: str, domainFull: str,
def htmlLinksMobile(cssCache: {}, base_dir: str, def htmlLinksMobile(cssCache: {}, base_dir: str,
nickname: str, domainFull: str, nickname: str, domain_full: str,
http_prefix: str, translate, http_prefix: str, translate,
timelinePath: str, authorized: bool, timelinePath: str, authorized: bool,
rss_icon_at_top: bool, rss_icon_at_top: bool,
@ -374,7 +374,7 @@ def htmlLinksMobile(cssCache: {}, base_dir: str,
editor = isEditor(base_dir, nickname) editor = isEditor(base_dir, nickname)
artist = isArtist(base_dir, nickname) artist = isArtist(base_dir, nickname)
domain = removeDomainPort(domainFull) domain = removeDomainPort(domain_full)
instanceTitle = \ instanceTitle = \
getConfigParam(base_dir, 'instanceTitle') getConfigParam(base_dir, 'instanceTitle')
@ -394,7 +394,7 @@ def htmlLinksMobile(cssCache: {}, base_dir: str,
'links', authorized, 'links', authorized,
icons_as_buttons) + '</center>' icons_as_buttons) + '</center>'
htmlStr += \ htmlStr += \
getLeftColumnContent(base_dir, nickname, domainFull, getLeftColumnContent(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
editor, artist, editor, artist,
False, timelinePath, False, timelinePath,

View File

@ -47,7 +47,7 @@ def _votesIndicator(totalVotes: int, positive_voting: bool) -> str:
return totalVotesStr return totalVotesStr
def getRightColumnContent(base_dir: str, nickname: str, domainFull: str, def getRightColumnContent(base_dir: str, nickname: str, domain_full: str,
http_prefix: str, translate: {}, http_prefix: str, translate: {},
moderator: bool, editor: bool, moderator: bool, editor: bool,
newswire: {}, positive_voting: bool, newswire: {}, positive_voting: bool,
@ -65,7 +65,7 @@ def getRightColumnContent(base_dir: str, nickname: str, domainFull: str,
""" """
htmlStr = '' htmlStr = ''
domain = removeDomainPort(domainFull) domain = removeDomainPort(domain_full)
if authorized: if authorized:
# only show the publish button if logged in, otherwise replace it with # only show the publish button if logged in, otherwise replace it with
@ -445,7 +445,7 @@ def htmlCitations(base_dir: str, nickname: str, domain: str,
def htmlNewswireMobile(cssCache: {}, base_dir: str, nickname: str, def htmlNewswireMobile(cssCache: {}, base_dir: str, nickname: str,
domain: str, domainFull: str, domain: str, domain_full: str,
http_prefix: str, translate: {}, http_prefix: str, translate: {},
newswire: {}, newswire: {},
positive_voting: bool, positive_voting: bool,
@ -498,7 +498,7 @@ def htmlNewswireMobile(cssCache: {}, base_dir: str, nickname: str,
'newswire', authorized, 'newswire', authorized,
icons_as_buttons) + '</center>' icons_as_buttons) + '</center>'
htmlStr += \ htmlStr += \
getRightColumnContent(base_dir, nickname, domainFull, getRightColumnContent(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
moderator, editor, moderator, editor,
newswire, positive_voting, newswire, positive_voting,

View File

@ -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)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
postFilename = locatePost(base_dir, nickname, domain, messageId) postFilename = locatePost(base_dir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -85,7 +85,7 @@ def htmlConfirmDelete(cssCache: {},
' <p class="followText">' + \ ' <p class="followText">' + \
translate['Delete this post?'] + '</p>' translate['Delete this post?'] + '</p>'
postActor = getAltPath(actor, domainFull, callingDomain) postActor = getAltPath(actor, domain_full, callingDomain)
deletePostStr += \ deletePostStr += \
' <form method="POST" action="' + postActor + '/rmpost">\n' ' <form method="POST" action="' + postActor + '/rmpost">\n'
deletePostStr += \ deletePostStr += \
@ -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)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
sharesFile = \ sharesFile = \
acctDir(base_dir, nickname, domain) + '/' + sharesFileType + '.json' acctDir(base_dir, nickname, domain) + '/' + sharesFileType + '.json'
if not os.path.isfile(sharesFile): if not os.path.isfile(sharesFile):
@ -149,7 +149,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, base_dir: str,
sharesStr += \ sharesStr += \
' <p class="followText">' + translate['Remove'] + \ ' <p class="followText">' + translate['Remove'] + \
' ' + sharedItemDisplayName + ' ?</p>\n' ' ' + sharedItemDisplayName + ' ?</p>\n'
postActor = getAltPath(actor, domainFull, callingDomain) postActor = getAltPath(actor, domain_full, callingDomain)
if sharesFileType == 'shares': if sharesFileType == 'shares':
endpoint = 'rmshare' endpoint = 'rmshare'
else: else:

View File

@ -27,7 +27,7 @@ from webapp_post import individualPostAsHtml
def _htmlFollowingDataList(base_dir: str, nickname: str, def _htmlFollowingDataList(base_dir: str, nickname: str,
domain: str, domainFull: str) -> str: domain: str, domain_full: str) -> str:
"""Returns a datalist of handles being followed """Returns a datalist of handles being followed
""" """
listStr = '<datalist id="followingHandles">\n' listStr = '<datalist id="followingHandles">\n'
@ -39,7 +39,7 @@ def _htmlFollowingDataList(base_dir: str, nickname: str,
msg = followingFile.read() msg = followingFile.read()
# add your own handle, so that you can send DMs # add your own handle, so that you can send DMs
# to yourself as reminders # to yourself as reminders
msg += nickname + '@' + domainFull + '\n' msg += nickname + '@' + domain_full + '\n'
if msg: if msg:
# include petnames # include petnames
petnamesFilename = \ petnamesFilename = \
@ -192,7 +192,7 @@ def htmlNewPost(cssCache: {}, media_instance: bool, translate: {},
reportUrl: str, pageNumber: int, reportUrl: str, pageNumber: int,
category: str, category: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, domain_full: str,
defaultTimeline: str, newswire: {}, defaultTimeline: str, newswire: {},
theme: str, noDropDown: bool, theme: str, noDropDown: bool,
accessKeys: {}, customSubmitText: str, accessKeys: {}, customSubmitText: str,
@ -812,7 +812,7 @@ def htmlNewPost(cssCache: {}, media_instance: bool, translate: {},
' <input type="text" name="mentions" ' + \ ' <input type="text" name="mentions" ' + \
'list="followingHandles" value="' + mentionsStr + '" selected>\n' 'list="followingHandles" value="' + mentionsStr + '" selected>\n'
newPostForm += \ newPostForm += \
_htmlFollowingDataList(base_dir, nickname, domain, domainFull) _htmlFollowingDataList(base_dir, nickname, domain, domain_full)
newPostForm += '' newPostForm += ''
selectedStr = '' selectedStr = ''

View File

@ -125,9 +125,9 @@ def htmlFrontScreen(signing_priv_key_pem: str,
domain, port = getDomainFromActor(profileJson['id']) domain, port = getDomainFromActor(profileJson['id'])
if not domain: if not domain:
return "" return ""
domainFull = domain domain_full = domain
if port: if port:
domainFull = domain + ':' + str(port) domain_full = domain + ':' + str(port)
loginButton = headerButtonsFrontScreen(translate, nickname, loginButton = headerButtonsFrontScreen(translate, nickname,
'features', authorized, 'features', authorized,
@ -153,7 +153,7 @@ def htmlFrontScreen(signing_priv_key_pem: str,
' <tr>\n' + \ ' <tr>\n' + \
' <td valign="top" class="col-left">\n' ' <td valign="top" class="col-left">\n'
profileHeaderStr += \ profileHeaderStr += \
getLeftColumnContent(base_dir, 'news', domainFull, getLeftColumnContent(base_dir, 'news', domain_full,
http_prefix, translate, http_prefix, translate,
False, False, False, False,
False, None, rss_icon_at_top, True, False, None, rss_icon_at_top, True,
@ -193,7 +193,7 @@ def htmlFrontScreen(signing_priv_key_pem: str,
profileFooterStr = ' </td>\n' profileFooterStr = ' </td>\n'
profileFooterStr += ' <td valign="top" class="col-right">\n' profileFooterStr += ' <td valign="top" class="col-right">\n'
profileFooterStr += \ profileFooterStr += \
getRightColumnContent(base_dir, 'news', domainFull, getRightColumnContent(base_dir, 'news', domain_full,
http_prefix, translate, http_prefix, translate,
False, False, newswire, False, False, False, newswire, False,
False, None, False, False, False, None, False, False,

View File

@ -33,7 +33,7 @@ from webapp_utils import htmlKeyboardNavigation
def htmlPersonOptions(defaultTimeline: str, def htmlPersonOptions(defaultTimeline: str,
cssCache: {}, translate: {}, base_dir: str, cssCache: {}, translate: {}, base_dir: str,
domain: str, domainFull: str, domain: str, domain_full: str,
originPathStr: str, originPathStr: str,
optionsActor: str, optionsActor: str,
optionsProfileUrl: str, optionsProfileUrl: str,
@ -288,7 +288,7 @@ def htmlPersonOptions(defaultTimeline: str,
# checkbox for permission to post to newswire # checkbox for permission to post to newswire
newswirePostsPermitted = False newswirePostsPermitted = False
if optionsDomainFull == domainFull: if optionsDomainFull == domain_full:
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
if (nickname == adminNickname or if (nickname == adminNickname or
(isModerator(base_dir, nickname) and (isModerator(base_dir, nickname) and
@ -329,7 +329,7 @@ def htmlPersonOptions(defaultTimeline: str,
optionsStr += checkboxStr optionsStr += checkboxStr
# checkbox for permission to post to featured articles # checkbox for permission to post to featured articles
if news_instance and optionsDomainFull == domainFull: if news_instance and optionsDomainFull == domain_full:
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
if (nickname == adminNickname or if (nickname == adminNickname or
(isModerator(base_dir, nickname) and (isModerator(base_dir, nickname) and

View File

@ -331,7 +331,7 @@ def _getPostFromRecentCache(session,
def _getAvatarImageHtml(showAvatarOptions: bool, def _getAvatarImageHtml(showAvatarOptions: bool,
nickname: str, domainFull: str, nickname: str, domain_full: str,
avatarUrl: str, postActor: str, avatarUrl: str, postActor: str,
translate: {}, avatarPosition: str, translate: {}, avatarPosition: str,
pageNumber: int, messageIdStr: str) -> str: pageNumber: int, messageIdStr: str) -> str:
@ -349,7 +349,7 @@ def _getAvatarImageHtml(showAvatarOptions: bool,
getBrokenLinkSubstitute() + '/></a>\n' getBrokenLinkSubstitute() + '/></a>\n'
if showAvatarOptions and \ if showAvatarOptions and \
domainFull + '/users/' + nickname not in postActor: domain_full + '/users/' + nickname not in postActor:
showOptionsForThisPersonStr = 'Show options for this person' showOptionsForThisPersonStr = 'Show options for this person'
if translate.get(showOptionsForThisPersonStr): if translate.get(showOptionsForThisPersonStr):
showOptionsForThisPersonStr = \ showOptionsForThisPersonStr = \
@ -460,7 +460,7 @@ def _getReplyIconHtml(base_dir: str, nickname: str, domain: str,
return replyStr return replyStr
def _getEditIconHtml(base_dir: str, nickname: str, domainFull: str, def _getEditIconHtml(base_dir: str, nickname: str, domain_full: str,
post_json_object: {}, actorNickname: str, post_json_object: {}, actorNickname: str,
translate: {}, isEvent: bool) -> str: translate: {}, isEvent: bool) -> str:
"""Returns html for the edit icon/button """Returns html for the edit icon/button
@ -471,9 +471,9 @@ def _getEditIconHtml(base_dir: str, nickname: str, domainFull: str,
# or it could be generated from the newswire (see # or it could be generated from the newswire (see
# _addBlogsToNewswire) in which case anyone with # _addBlogsToNewswire) in which case anyone with
# editor status should be able to alter it # editor status should be able to alter it
if (actor.endswith('/' + domainFull + '/users/' + nickname) or if (actor.endswith('/' + domain_full + '/users/' + nickname) or
(isEditor(base_dir, nickname) and (isEditor(base_dir, nickname) and
actor.endswith('/' + domainFull + '/users/news'))): actor.endswith('/' + domain_full + '/users/news'))):
postId = removeIdEnding(post_json_object['object']['id']) postId = removeIdEnding(post_json_object['object']['id'])
@ -526,7 +526,7 @@ def _getEditIconHtml(base_dir: str, nickname: str, domainFull: str,
def _getAnnounceIconHtml(isAnnounced: bool, def _getAnnounceIconHtml(isAnnounced: bool,
postActor: str, postActor: str,
nickname: str, domainFull: str, nickname: str, domain_full: str,
announceJsonObject: {}, announceJsonObject: {},
post_json_object: {}, post_json_object: {},
isPublicRepeat: bool, isPublicRepeat: bool,
@ -559,7 +559,7 @@ def _getAnnounceIconHtml(isAnnounced: bool,
unannounceLinkStr = '' unannounceLinkStr = ''
if announcedByPerson(isAnnounced, if announcedByPerson(isAnnounced,
postActor, nickname, domainFull): postActor, nickname, domain_full):
announceIcon = 'repeat.png' announceIcon = 'repeat.png'
announceEmoji = '🔁 ' announceEmoji = '🔁 '
announceLink = 'unrepeat' announceLink = 'unrepeat'
@ -592,7 +592,7 @@ def _getAnnounceIconHtml(isAnnounced: bool,
return announceStr return announceStr
def _getLikeIconHtml(nickname: str, domainFull: str, def _getLikeIconHtml(nickname: str, domain_full: str,
isModerationPost: bool, isModerationPost: bool,
showLikeButton: bool, showLikeButton: bool,
post_json_object: {}, post_json_object: {},
@ -623,7 +623,7 @@ def _getLikeIconHtml(nickname: str, domainFull: str,
likeCountStr = ' (' + str(likeCount) + ')' likeCountStr = ' (' + str(likeCount) + ')'
else: else:
likeCountStr = ' (' + str(max_like_count) + '+)' likeCountStr = ' (' + str(max_like_count) + '+)'
if likedByPerson(post_json_object, nickname, domainFull): if likedByPerson(post_json_object, nickname, domain_full):
if likeCount == 1: if likeCount == 1:
# liked by the reader only # liked by the reader only
likeCountStr = '' likeCountStr = ''
@ -660,7 +660,7 @@ def _getLikeIconHtml(nickname: str, domainFull: str,
return likeStr return likeStr
def _getBookmarkIconHtml(nickname: str, domainFull: str, def _getBookmarkIconHtml(nickname: str, domain_full: str,
post_json_object: {}, post_json_object: {},
isModerationPost: bool, isModerationPost: bool,
translate: {}, translate: {},
@ -681,7 +681,7 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str,
bookmarkTitle = 'Bookmark this post' bookmarkTitle = 'Bookmark this post'
if translate.get(bookmarkTitle): if translate.get(bookmarkTitle):
bookmarkTitle = translate[bookmarkTitle] bookmarkTitle = translate[bookmarkTitle]
if bookmarkedByPerson(post_json_object, nickname, domainFull): if bookmarkedByPerson(post_json_object, nickname, domain_full):
bookmarkIcon = 'bookmark.png' bookmarkIcon = 'bookmark.png'
bookmarkLink = 'unbookmark' bookmarkLink = 'unbookmark'
bookmarkEmoji = '🔖 ' bookmarkEmoji = '🔖 '
@ -706,7 +706,7 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str,
return bookmarkStr return bookmarkStr
def _getReactionIconHtml(nickname: str, domainFull: str, def _getReactionIconHtml(nickname: str, domain_full: str,
post_json_object: {}, post_json_object: {},
isModerationPost: bool, isModerationPost: bool,
showReactionButton: bool, showReactionButton: bool,
@ -746,7 +746,7 @@ def _getReactionIconHtml(nickname: str, domainFull: str,
def _getMuteIconHtml(isMuted: bool, def _getMuteIconHtml(isMuted: bool,
postActor: str, postActor: str,
messageId: str, messageId: str,
nickname: str, domainFull: str, nickname: str, domain_full: str,
allow_deletion: bool, allow_deletion: bool,
pageNumberParam: str, pageNumberParam: str,
boxName: str, boxName: str,
@ -756,7 +756,7 @@ def _getMuteIconHtml(isMuted: bool,
""" """
muteStr = '' muteStr = ''
if (allow_deletion or if (allow_deletion or
('/' + domainFull + '/' in postActor and ('/' + domain_full + '/' in postActor and
messageId.startswith(postActor))): messageId.startswith(postActor))):
return muteStr return muteStr
@ -792,7 +792,7 @@ def _getMuteIconHtml(isMuted: bool,
return muteStr return muteStr
def _getDeleteIconHtml(nickname: str, domainFull: str, def _getDeleteIconHtml(nickname: str, domain_full: str,
allow_deletion: bool, allow_deletion: bool,
postActor: str, postActor: str,
messageId: str, messageId: str,
@ -803,7 +803,7 @@ def _getDeleteIconHtml(nickname: str, domainFull: str,
""" """
deleteStr = '' deleteStr = ''
if (allow_deletion or if (allow_deletion or
('/' + domainFull + '/' in postActor and ('/' + domain_full + '/' in postActor and
messageId.startswith(postActor))): messageId.startswith(postActor))):
if '/users/' + nickname + '/' in messageId: if '/users/' + nickname + '/' in messageId:
if not isNewsPost(post_json_object): if not isNewsPost(post_json_object):
@ -1381,7 +1381,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
if messageId: if messageId:
messageIdStr = ';' + messageId messageIdStr = ';' + messageId
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
pageNumberParam = '' pageNumberParam = ''
if pageNumber: if pageNumber:
@ -1422,7 +1422,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_logPostTiming(enableTimingLog, postStartTime, '5') _logPostTiming(enableTimingLog, postStartTime, '5')
# get the display name # get the display name
if domainFull not in postActor: if domain_full not in postActor:
# 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)
@ -1465,7 +1465,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
avatarLink = \ avatarLink = \
_getAvatarImageHtml(showAvatarOptions, _getAvatarImageHtml(showAvatarOptions,
nickname, domainFull, nickname, domain_full,
avatarUrl, postActor, avatarUrl, postActor,
translate, avatarPosition, translate, avatarPosition,
pageNumber, messageIdStr) pageNumber, messageIdStr)
@ -1504,7 +1504,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
allow_local_network_access, allow_local_network_access,
recentPostsCache, False, recentPostsCache, False,
system_language, system_language,
domainFull, person_cache, domain_full, person_cache,
signing_priv_key_pem, signing_priv_key_pem,
blockedCache) blockedCache)
if not postJsonAnnounce: if not postJsonAnnounce:
@ -1541,14 +1541,14 @@ def individualPostAsHtml(signing_priv_key_pem: str,
if announceFilename: if announceFilename:
updateAnnounceCollection(recentPostsCache, updateAnnounceCollection(recentPostsCache,
base_dir, announceFilename, base_dir, announceFilename,
postActor, nickname, domainFull, False) postActor, nickname, domain_full, False)
# create a file for use by text-to-speech # create a file for use by text-to-speech
if isRecentPost(post_json_object, 3): if isRecentPost(post_json_object, 3):
if post_json_object.get('actor'): if post_json_object.get('actor'):
if not os.path.isfile(announceFilename + '.tts'): if not os.path.isfile(announceFilename + '.tts'):
updateSpeaker(base_dir, http_prefix, updateSpeaker(base_dir, http_prefix,
nickname, domain, domainFull, nickname, domain, domain_full,
post_json_object, person_cache, post_json_object, person_cache,
translate, post_json_object['actor'], translate, post_json_object['actor'],
theme_name) theme_name)
@ -1644,7 +1644,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_logPostTiming(enableTimingLog, postStartTime, '10') _logPostTiming(enableTimingLog, postStartTime, '10')
editStr = _getEditIconHtml(base_dir, nickname, domainFull, editStr = _getEditIconHtml(base_dir, nickname, domain_full,
post_json_object, actorNickname, post_json_object, actorNickname,
translate, False) translate, False)
@ -1653,7 +1653,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
announceStr = \ announceStr = \
_getAnnounceIconHtml(isAnnounced, _getAnnounceIconHtml(isAnnounced,
postActor, postActor,
nickname, domainFull, nickname, domain_full,
announceJsonObject, announceJsonObject,
post_json_object, post_json_object,
isPublicRepeat, isPublicRepeat,
@ -1683,7 +1683,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
likeJsonObject = post_json_object likeJsonObject = post_json_object
if announceJsonObject: if announceJsonObject:
likeJsonObject = announceJsonObject likeJsonObject = announceJsonObject
likeStr = _getLikeIconHtml(nickname, domainFull, likeStr = _getLikeIconHtml(nickname, domain_full,
isModerationPost, isModerationPost,
showLikeButton, showLikeButton,
likeJsonObject, likeJsonObject,
@ -1696,7 +1696,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_logPostTiming(enableTimingLog, postStartTime, '12.5') _logPostTiming(enableTimingLog, postStartTime, '12.5')
bookmarkStr = \ bookmarkStr = \
_getBookmarkIconHtml(nickname, domainFull, _getBookmarkIconHtml(nickname, domain_full,
post_json_object, post_json_object,
isModerationPost, isModerationPost,
translate, translate,
@ -1708,7 +1708,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_logPostTiming(enableTimingLog, postStartTime, '12.9') _logPostTiming(enableTimingLog, postStartTime, '12.9')
reactionStr = \ reactionStr = \
_getReactionIconHtml(nickname, domainFull, _getReactionIconHtml(nickname, domain_full,
post_json_object, post_json_object,
isModerationPost, isModerationPost,
showReactionButton, showReactionButton,
@ -1729,7 +1729,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
_getMuteIconHtml(isMuted, _getMuteIconHtml(isMuted,
postActor, postActor,
messageId, messageId,
nickname, domainFull, nickname, domain_full,
allow_deletion, allow_deletion,
pageNumberParam, pageNumberParam,
boxName, boxName,
@ -1737,7 +1737,7 @@ def individualPostAsHtml(signing_priv_key_pem: str,
translate) translate)
deleteStr = \ deleteStr = \
_getDeleteIconHtml(nickname, domainFull, _getDeleteIconHtml(nickname, domain_full,
allow_deletion, allow_deletion,
postActor, postActor,
messageId, messageId,
@ -1848,8 +1848,8 @@ 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']
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
personUrl = localActorUrl(http_prefix, nickname, domainFull) personUrl = localActorUrl(http_prefix, nickname, domain_full)
actorJson = \ actorJson = \
getPersonFromCache(base_dir, personUrl, person_cache, False) getPersonFromCache(base_dir, personUrl, person_cache, False)
languagesUnderstood = [] languagesUnderstood = []
@ -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'
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(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'
@ -2042,7 +2042,7 @@ def htmlIndividualPost(cssCache: {},
followStr += \ followStr += \
' <input type="hidden" name="searchtext" value="' + \ ' <input type="hidden" name="searchtext" value="' + \
byStrHandle + '">\n' byStrHandle + '">\n'
if not isFollowingActor(base_dir, nickname, domainFull, byStr): if not isFollowingActor(base_dir, nickname, domain_full, byStr):
translateFollowStr = 'Follow' translateFollowStr = 'Follow'
if translate.get(translateFollowStr): if translate.get(translateFollowStr):
translateFollowStr = translate[translateFollowStr] translateFollowStr = translate[translateFollowStr]

View File

@ -271,16 +271,16 @@ def htmlProfileAfterSearch(cssCache: {},
alsoKnownAs, accessKeys, alsoKnownAs, accessKeys,
joinedDate) joinedDate)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
followIsPermitted = True followIsPermitted = True
if not profileJson.get('followers'): if not profileJson.get('followers'):
# no followers collection specified within actor # no followers collection specified within actor
followIsPermitted = False followIsPermitted = False
elif searchNickname == 'news' and searchDomainFull == domainFull: elif searchNickname == 'news' and searchDomainFull == domain_full:
# currently the news actor is not something you can follow # currently the news actor is not something you can follow
followIsPermitted = False followIsPermitted = False
elif searchNickname == nickname and searchDomainFull == domainFull: elif searchNickname == nickname and searchDomainFull == domain_full:
# don't follow yourself! # don't follow yourself!
followIsPermitted = False followIsPermitted = False
@ -363,7 +363,7 @@ def htmlProfileAfterSearch(cssCache: {},
def _getProfileHeader(base_dir: str, http_prefix: str, def _getProfileHeader(base_dir: str, http_prefix: str,
nickname: str, domain: str, nickname: str, domain: str,
domainFull: str, translate: {}, domain_full: str, translate: {},
defaultTimeline: str, defaultTimeline: str,
displayName: str, displayName: str,
avatarDescription: str, avatarDescription: str,
@ -401,7 +401,7 @@ def _getProfileHeader(base_dir: str, http_prefix: str,
htmlStr += ' <h1>' + displayName + '</h1>\n' + occupationStr htmlStr += ' <h1>' + displayName + '</h1>\n' + occupationStr
htmlStr += \ htmlStr += \
' <p><b>@' + nickname + '@' + domainFull + '</b><br>\n' ' <p><b>@' + nickname + '@' + domain_full + '</b><br>\n'
if joinedDate: if joinedDate:
htmlStr += \ htmlStr += \
' <p>' + translate['Joined'] + ' ' + \ ' <p>' + translate['Joined'] + ' ' + \
@ -419,7 +419,7 @@ def _getProfileHeader(base_dir: str, http_prefix: str,
otherAccountsHtml = \ otherAccountsHtml = \
' <p>' + translate['Other accounts'] + ': ' ' <p>' + translate['Other accounts'] + ': '
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
ctr = 0 ctr = 0
if isinstance(alsoKnownAs, list): if isinstance(alsoKnownAs, list):
for altActor in alsoKnownAs: for altActor in alsoKnownAs:
@ -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,
profileJson['name'], True) profileJson['name'], True)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
profileDescription = \ profileDescription = \
addEmojiToDisplayName(session, base_dir, http_prefix, addEmojiToDisplayName(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
@ -828,10 +828,11 @@ def htmlProfile(signing_priv_key_pem: str,
avatarUrl = profileJson['icon']['url'] avatarUrl = profileJson['icon']['url']
# use alternate path for local avatars to avoid any caching issues # use alternate path for local avatars to avoid any caching issues
if '://' + domainFull + '/system/accounts/avatars/' in avatarUrl: if '://' + domain_full + '/system/accounts/avatars/' in avatarUrl:
avatarUrl = \ avatarUrl = \
avatarUrl.replace('://' + domainFull + '/system/accounts/avatars/', avatarUrl.replace('://' + domain_full +
'://' + domainFull + '/users/') '/system/accounts/avatars/',
'://' + domain_full + '/users/')
# get pinned post content # get pinned post content
accountDir = acctDir(base_dir, nickname, domain) accountDir = acctDir(base_dir, nickname, domain)
@ -844,7 +845,7 @@ def htmlProfile(signing_priv_key_pem: str,
profileHeaderStr = \ profileHeaderStr = \
_getProfileHeader(base_dir, http_prefix, _getProfileHeader(base_dir, http_prefix,
nickname, domain, nickname, domain,
domainFull, translate, domain_full, translate,
defaultTimeline, displayName, defaultTimeline, displayName,
avatarDescription, avatarDescription,
profileDescriptionShort, profileDescriptionShort,
@ -996,20 +997,20 @@ def htmlProfile(signing_priv_key_pem: str,
if not isGroup: if not isGroup:
if selected == 'roles': if selected == 'roles':
profileStr += \ profileStr += \
_htmlProfileRoles(translate, nickname, domainFull, _htmlProfileRoles(translate, nickname, domain_full,
extraJson) extraJson)
elif selected == 'skills': elif selected == 'skills':
profileStr += \ profileStr += \
_htmlProfileSkills(translate, nickname, domainFull, extraJson) _htmlProfileSkills(translate, nickname, domain_full, extraJson)
# elif selected == 'shares': # elif selected == 'shares':
# profileStr += \ # profileStr += \
# _htmlProfileShares(actor, translate, # _htmlProfileShares(actor, translate,
# nickname, domainFull, # nickname, domain_full,
# extraJson, 'shares') + licenseStr # extraJson, 'shares') + licenseStr
# elif selected == 'wanted': # elif selected == 'wanted':
# profileStr += \ # profileStr += \
# _htmlProfileShares(actor, translate, # _htmlProfileShares(actor, translate,
# nickname, domainFull, # nickname, domain_full,
# extraJson, 'wanted') + licenseStr # extraJson, 'wanted') + licenseStr
# end of #timeline # end of #timeline
profileStr += '</div>' profileStr += '</div>'
@ -2053,7 +2054,7 @@ def _htmlEditProfileMain(base_dir: str, displayNickname: str, bioStr: str,
def _htmlEditProfileTopBanner(base_dir: str, def _htmlEditProfileTopBanner(base_dir: str,
nickname: str, domain: str, domainFull: str, nickname: str, domain: str, domain_full: str,
defaultTimeline: str, bannerFile: str, defaultTimeline: str, bannerFile: str,
path: str, accessKeys: {}, translate: {}) -> str: path: str, accessKeys: {}, translate: {}) -> str:
"""top banner on edit profile screen """top banner on edit profile screen
@ -2069,7 +2070,7 @@ def _htmlEditProfileTopBanner(base_dir: str,
editProfileForm += ' <div class="vertical-center">\n' editProfileForm += ' <div class="vertical-center">\n'
editProfileForm += \ editProfileForm += \
' <h1>' + translate['Profile for'] + \ ' <h1>' + translate['Profile for'] + \
' ' + nickname + '@' + domainFull + '</h1>' ' ' + nickname + '@' + domain_full + '</h1>'
editProfileForm += ' <div class="container">\n' editProfileForm += ' <div class="container">\n'
editProfileForm += \ editProfileForm += \
' <center>\n' + \ ' <center>\n' + \
@ -2104,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 ''
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actorFilename = acctDir(base_dir, nickname, domain) + '.json' actorFilename = acctDir(base_dir, nickname, domain) + '.json'
if not os.path.isfile(actorFilename): if not os.path.isfile(actorFilename):
@ -2257,7 +2258,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, base_dir: str, path: str,
# top banner # top banner
editProfileForm += \ editProfileForm += \
_htmlEditProfileTopBanner(base_dir, nickname, domain, domainFull, _htmlEditProfileTopBanner(base_dir, nickname, domain, domain_full,
defaultTimeline, bannerFile, defaultTimeline, bannerFile,
path, accessKeys, translate) path, accessKeys, translate)

View File

@ -133,13 +133,13 @@ def _matchSharedItem(searchStrLowerList: [],
return False return False
def _htmlSearchResultSharePage(actor: str, domainFull: str, def _htmlSearchResultSharePage(actor: str, domain_full: str,
callingDomain: str, pageNumber: int, callingDomain: str, pageNumber: int,
searchStrLower: str, translate: {}, searchStrLower: str, translate: {},
previous: bool) -> str: previous: bool) -> str:
"""Returns the html for the previous button on shared items search results """Returns the html for the previous button on shared items search results
""" """
postActor = getAltPath(actor, domainFull, callingDomain) postActor = getAltPath(actor, domain_full, callingDomain)
# previous page link, needs to be a POST # previous page link, needs to be a POST
if previous: if previous:
pageNumber -= 1 pageNumber -= 1
@ -172,7 +172,7 @@ def _htmlSearchResultSharePage(actor: str, domainFull: str,
def _htmlSharesResult(base_dir: str, def _htmlSharesResult(base_dir: str,
sharesJson: {}, pageNumber: int, resultsPerPage: int, sharesJson: {}, pageNumber: int, resultsPerPage: int,
searchStrLowerList: [], currPage: int, ctr: int, searchStrLowerList: [], currPage: int, ctr: int,
callingDomain: str, http_prefix: str, domainFull: str, callingDomain: str, http_prefix: str, domain_full: str,
contactNickname: str, actor: str, contactNickname: str, actor: str,
resultsExist: bool, searchStrLower: str, translate: {}, resultsExist: bool, searchStrLower: str, translate: {},
sharesFileType: str) -> (bool, int, int, str): sharesFileType: str) -> (bool, int, int, str):
@ -188,14 +188,14 @@ def _htmlSharesResult(base_dir: str,
# show individual search result # show individual search result
sharedItemsForm += \ sharedItemsForm += \
htmlSearchResultShare(base_dir, sharedItem, translate, htmlSearchResultShare(base_dir, sharedItem, translate,
http_prefix, domainFull, http_prefix, domain_full,
contactNickname, contactNickname,
name, actor, sharesFileType, name, actor, sharesFileType,
sharedItem['category']) sharedItem['category'])
if not resultsExist and currPage > 1: if not resultsExist and currPage > 1:
# show the previous page button # show the previous page button
sharedItemsForm += \ sharedItemsForm += \
_htmlSearchResultSharePage(actor, domainFull, _htmlSearchResultSharePage(actor, domain_full,
callingDomain, callingDomain,
pageNumber, pageNumber,
searchStrLower, searchStrLower,
@ -207,7 +207,7 @@ def _htmlSharesResult(base_dir: str,
if currPage > pageNumber: if currPage > pageNumber:
# show the next page button # show the next page button
sharedItemsForm += \ sharedItemsForm += \
_htmlSearchResultSharePage(actor, domainFull, _htmlSearchResultSharePage(actor, domain_full,
callingDomain, callingDomain,
pageNumber, pageNumber,
searchStrLower, searchStrLower,
@ -222,7 +222,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
pageNumber: int, pageNumber: int,
resultsPerPage: int, resultsPerPage: int,
http_prefix: str, http_prefix: str,
domainFull: str, actor: str, domain_full: str, actor: str,
callingDomain: str, callingDomain: str,
shared_items_federated_domains: [], shared_items_federated_domains: [],
sharesFileType: str) -> str: sharesFileType: str) -> str:
@ -270,7 +270,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
searchStrLowerList, searchStrLowerList,
currPage, ctr, currPage, ctr,
callingDomain, http_prefix, callingDomain, http_prefix,
domainFull, domain_full,
contactNickname, contactNickname,
actor, resultsExist, actor, resultsExist,
searchStrLower, translate, searchStrLower, translate,
@ -308,7 +308,7 @@ def htmlSearchSharedItems(cssCache: {}, translate: {},
searchStrLowerList, searchStrLowerList,
currPage, ctr, currPage, ctr,
callingDomain, http_prefix, callingDomain, http_prefix,
domainFull, domain_full,
contactNickname, contactNickname,
actor, resultsExist, actor, resultsExist,
searchStrLower, translate, searchStrLower, translate,
@ -629,8 +629,8 @@ def htmlHistorySearch(cssCache: {}, translate: {}, base_dir: str,
htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
# add the page title # add the page title
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
historySearchTitle = '🔍 ' + translate['Your Posts'] historySearchTitle = '🔍 ' + translate['Your Posts']
if boxName == 'bookmarks': if boxName == 'bookmarks':
historySearchTitle = '🔍 ' + translate['Bookmarks'] historySearchTitle = '🔍 ' + translate['Bookmarks']
@ -933,11 +933,11 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
if not lines: if not lines:
return None return None
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
maxFeedLength = 10 maxFeedLength = 10
hashtagFeed = \ hashtagFeed = \
rss2TagHeader(hashtag, http_prefix, domainFull) rss2TagHeader(hashtag, http_prefix, domain_full)
for index in range(len(lines)): for index in range(len(lines)):
postId = lines[index].strip('\n').strip('\r') postId = lines[index].strip('\n').strip('\r')
if ' ' not in postId: if ' ' not in postId:

View File

@ -357,7 +357,7 @@ def _htmlTimelineKeyboard(moderator: bool, text_mode_banner: str,
None, usersPath, translate, followApprovals) None, usersPath, translate, followApprovals)
def _htmlTimelineEnd(base_dir: str, nickname: str, domainFull: str, def _htmlTimelineEnd(base_dir: str, nickname: str, domain_full: str,
http_prefix: str, translate: {}, http_prefix: str, translate: {},
moderator: bool, editor: bool, moderator: bool, editor: bool,
newswire: {}, positive_voting: bool, newswire: {}, positive_voting: bool,
@ -376,7 +376,7 @@ def _htmlTimelineEnd(base_dir: str, nickname: str, domainFull: str,
tlStr += ' </td>\n' tlStr += ' </td>\n'
# right column # right column
rightColumnStr = getRightColumnContent(base_dir, nickname, domainFull, rightColumnStr = getRightColumnContent(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
moderator, editor, moderator, editor,
newswire, positive_voting, newswire, positive_voting,
@ -741,11 +741,11 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
' <tbody>\n' + \ ' <tbody>\n' + \
' <tr>\n' ' <tr>\n'
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
# left column # left column
leftColumnStr = \ leftColumnStr = \
getLeftColumnContent(base_dir, nickname, domainFull, getLeftColumnContent(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
editor, artist, False, None, rss_icon_at_top, editor, artist, False, None, rss_icon_at_top,
True, False, theme, accessKeys, True, False, theme, accessKeys,
@ -789,7 +789,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
base_dir, actor, nickname, domain, port, base_dir, actor, nickname, domain, port,
maxSharesPerAccount, http_prefix, maxSharesPerAccount, http_prefix,
shared_items_federated_domains, 'shares') + shared_items_federated_domains, 'shares') +
_htmlTimelineEnd(base_dir, nickname, domainFull, _htmlTimelineEnd(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
moderator, editor, moderator, editor,
newswire, positive_voting, newswire, positive_voting,
@ -807,7 +807,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
base_dir, actor, nickname, domain, port, base_dir, actor, nickname, domain, port,
maxSharesPerAccount, http_prefix, maxSharesPerAccount, http_prefix,
shared_items_federated_domains, 'wanted') + shared_items_federated_domains, 'wanted') +
_htmlTimelineEnd(base_dir, nickname, domainFull, _htmlTimelineEnd(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
moderator, editor, moderator, editor,
newswire, positive_voting, newswire, positive_voting,
@ -955,7 +955,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
tlStr += _getHelpForTimeline(base_dir, boxName) tlStr += _getHelpForTimeline(base_dir, boxName)
tlStr += \ tlStr += \
_htmlTimelineEnd(base_dir, nickname, domainFull, _htmlTimelineEnd(base_dir, nickname, domain_full,
http_prefix, translate, http_prefix, translate,
moderator, editor, moderator, editor,
newswire, positive_voting, newswire, positive_voting,
@ -1053,13 +1053,13 @@ 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)
domainFull = getFullDomain(domain, port) domain_full = getFullDomain(domain, port)
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
adminActor = '' adminActor = ''
if adminNickname: if adminNickname:
adminActor = \ adminActor = \
localActorUrl(http_prefix, adminNickname, domainFull) localActorUrl(http_prefix, adminNickname, domain_full)
timelineStr = '' timelineStr = ''
if pageNumber > 1: if pageNumber > 1:

View File

@ -17,7 +17,7 @@ from markdown import markdownToHtml
def htmlTermsOfService(cssCache: {}, base_dir: str, def htmlTermsOfService(cssCache: {}, base_dir: str,
http_prefix: str, domainFull: str) -> str: http_prefix: str, domain_full: str) -> str:
"""Show the terms of service screen """Show the terms of service screen
""" """
adminNickname = getConfigParam(base_dir, 'admin') adminNickname = getConfigParam(base_dir, 'admin')
@ -45,7 +45,7 @@ def htmlTermsOfService(cssCache: {}, base_dir: str,
TOSForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None) TOSForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle, None)
TOSForm += '<div class="container">' + TOSText + '</div>\n' TOSForm += '<div class="container">' + TOSText + '</div>\n'
if adminNickname: if adminNickname:
adminActor = localActorUrl(http_prefix, adminNickname, domainFull) adminActor = localActorUrl(http_prefix, adminNickname, domain_full)
TOSForm += \ TOSForm += \
'<div class="container"><center>\n' + \ '<div class="container"><center>\n' + \
'<p class="administeredby">Administered by <a href="' + \ '<p class="administeredby">Administered by <a href="' + \

View File

@ -652,8 +652,8 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
description = removeHtml(actorJson['summary']) description = removeHtml(actorJson['summary'])
nameStr = removeHtml(actorJson['name']) nameStr = removeHtml(actorJson['name'])
domainFull = actorJson['id'].split('://')[1].split('/')[0] domain_full = actorJson['id'].split('://')[1].split('/')[0]
handle = actorJson['preferredUsername'] + '@' + domainFull handle = actorJson['preferredUsername'] + '@' + domain_full
personMarkup = \ personMarkup = \
' "about": {\n' + \ ' "about": {\n' + \
@ -696,7 +696,7 @@ def htmlHeaderWithPersonMarkup(cssFilename: str, instanceTitle: str,
"\" name='description'>\n" + \ "\" name='description'>\n" + \
" <meta content=\"" + actorJson['url'] + \ " <meta content=\"" + actorJson['url'] + \
"\" property=\"og:url\" />\n" + \ "\" property=\"og:url\" />\n" + \
" <meta content=\"" + domainFull + \ " <meta content=\"" + domain_full + \
"\" property=\"og:site_name\" />\n" + \ "\" property=\"og:site_name\" />\n" + \
" <meta content=\"" + nameStr + " (@" + handle + \ " <meta content=\"" + nameStr + " (@" + handle + \
")\" property=\"og:title\" />\n" + \ ")\" property=\"og:title\" />\n" + \
@ -1406,7 +1406,7 @@ def editTextArea(label: str, name: str, value: str,
def htmlSearchResultShare(base_dir: str, sharedItem: {}, translate: {}, def htmlSearchResultShare(base_dir: str, sharedItem: {}, translate: {},
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
contactNickname: str, itemID: str, contactNickname: str, itemID: str,
actor: str, sharesFileType: str, actor: str, sharesFileType: str,
category: str) -> str: category: str) -> str:
@ -1448,7 +1448,7 @@ def htmlSearchResultShare(base_dir: str, sharedItem: {}, translate: {},
contactTitleStr = translate['Buy'] contactTitleStr = translate['Buy']
sharedItemsForm += '</p>\n' sharedItemsForm += '</p>\n'
contactActor = \ contactActor = \
localActorUrl(http_prefix, contactNickname, domainFull) localActorUrl(http_prefix, contactNickname, domain_full)
buttonStyleStr = 'button' buttonStyleStr = 'button'
if category == 'accommodation': if category == 'accommodation':
contactTitleStr = translate['Request to stay'] contactTitleStr = translate['Request to stay']
@ -1493,7 +1493,7 @@ def htmlSearchResultShare(base_dir: str, sharedItem: {}, translate: {},
def htmlShowShare(base_dir: str, domain: str, nickname: str, def htmlShowShare(base_dir: str, domain: str, nickname: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
itemID: str, translate: {}, itemID: str, translate: {},
shared_items_federated_domains: [], shared_items_federated_domains: [],
defaultTimeline: str, theme: str, defaultTimeline: str, theme: str,
@ -1507,7 +1507,7 @@ def htmlShowShare(base_dir: str, domain: str, nickname: str,
if not contactNickname: if not contactNickname:
return None return None
if '://' + domainFull + '/' in shareUrl: if '://' + domain_full + '/' in shareUrl:
# shared item on this instance # shared item on this instance
sharesFilename = \ sharesFilename = \
acctDir(base_dir, contactNickname, domain) + '/' + \ acctDir(base_dir, contactNickname, domain) + '/' + \
@ -1545,7 +1545,7 @@ def htmlShowShare(base_dir: str, domain: str, nickname: str,
if not sharesJson.get(itemID): if not sharesJson.get(itemID):
return None return None
sharedItem = sharesJson[itemID] sharedItem = sharesJson[itemID]
actor = localActorUrl(http_prefix, nickname, domainFull) actor = localActorUrl(http_prefix, nickname, domain_full)
# filename of the banner shown at the top # filename of the banner shown at the top
bannerFile, bannerFilename = \ bannerFile, bannerFilename = \
@ -1561,7 +1561,7 @@ def htmlShowShare(base_dir: str, domain: str, nickname: str,
'</header><br>\n' '</header><br>\n'
shareStr += \ shareStr += \
htmlSearchResultShare(base_dir, sharedItem, translate, http_prefix, htmlSearchResultShare(base_dir, sharedItem, translate, http_prefix,
domainFull, contactNickname, itemID, domain_full, contactNickname, itemID,
actor, sharesFileType, category) actor, sharesFileType, category)
cssFilename = base_dir + '/epicyon-profile.css' cssFilename = base_dir + '/epicyon-profile.css'

View File

@ -17,7 +17,7 @@ from markdown import markdownToHtml
def htmlWelcomeFinal(base_dir: str, nickname: str, domain: str, def htmlWelcomeFinal(base_dir: str, nickname: str, domain: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
language: str, translate: {}, language: str, translate: {},
theme_name: str) -> str: theme_name: str) -> str:
"""Returns the final welcome screen after first login """Returns the final welcome screen after first login

View File

@ -23,7 +23,7 @@ from markdown import markdownToHtml
def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str, def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str,
http_prefix: str, domainFull: str, http_prefix: str, domain_full: str,
language: str, translate: {}, language: str, translate: {},
theme_name: str) -> str: theme_name: str) -> str:
"""Returns the welcome profile screen to set avatar and bio """Returns the welcome profile screen to set avatar and bio
@ -76,7 +76,7 @@ def htmlWelcomeProfile(base_dir: str, nickname: str, domain: str,
if os.path.isfile(avatarFilename): if os.path.isfile(avatarFilename):
break break
avatarUrl = \ avatarUrl = \
localActorUrl(http_prefix, nickname, domainFull) + '/avatar.' + ext localActorUrl(http_prefix, nickname, domain_full) + '/avatar.' + ext
imageFormats = getImageFormats() imageFormats = getImageFormats()
profileForm += '<div class="container">' + profileText + '</div>\n' profileForm += '<div class="container">' + profileText + '</div>\n'

View File

@ -181,13 +181,13 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
return account return account
def webfingerNodeInfo(http_prefix: str, domainFull: str) -> {}: def webfingerNodeInfo(http_prefix: str, domain_full: str) -> {}:
""" /.well-known/nodeinfo endpoint """ /.well-known/nodeinfo endpoint
""" """
nodeinfo = { nodeinfo = {
'links': [ 'links': [
{ {
'href': http_prefix + '://' + domainFull + '/nodeinfo/2.0', 'href': http_prefix + '://' + domain_full + '/nodeinfo/2.0',
'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0' 'rel': 'http://nodeinfo.diaspora.software/ns/schema/2.0'
} }
] ]
@ -195,7 +195,7 @@ def webfingerNodeInfo(http_prefix: str, domainFull: str) -> {}:
return nodeinfo return nodeinfo
def webfingerMeta(http_prefix: str, domainFull: str) -> str: def webfingerMeta(http_prefix: str, domain_full: str) -> str:
"""Return /.well-known/host-meta """Return /.well-known/host-meta
""" """
metaStr = \ metaStr = \
@ -203,10 +203,10 @@ def webfingerMeta(http_prefix: str, domainFull: str) -> str:
"<XRD xmlns=http://docs.oasis-open.org/ns/xri/xrd-1.0'" + \ "<XRD xmlns=http://docs.oasis-open.org/ns/xri/xrd-1.0'" + \
" xmlns:hm=http://host-meta.net/xrd/1.0'>" + \ " xmlns:hm=http://host-meta.net/xrd/1.0'>" + \
"" + \ "" + \
"<hm:Host>" + domainFull + "</hm:Host>" + \ "<hm:Host>" + domain_full + "</hm:Host>" + \
"" + \ "" + \
"<Link rel=lrdd" + \ "<Link rel=lrdd" + \
" template=" + http_prefix + "://" + domainFull + \ " template=" + http_prefix + "://" + domain_full + \
"/describe?uri={uri}'>" + \ "/describe?uri={uri}'>" + \
" <Title>Resource Descriptor</Title>" + \ " <Title>Resource Descriptor</Title>" + \
" </Link>" + \ " </Link>" + \