Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main

main
Bob Mottram 2020-12-17 23:30:15 +00:00
commit 39a6480064
51 changed files with 591 additions and 677 deletions

View File

@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
import os import os
from utils import getFullDomain
from utils import urlPermitted from utils import urlPermitted
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -30,10 +31,7 @@ def createAcceptReject(baseDir: str, federationList: [],
if not urlPermitted(objectJson['actor'], federationList): if not urlPermitted(objectJson['actor'], federationList):
return None return None
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
newAccept = { newAccept = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",

View File

@ -6,6 +6,7 @@ __maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net" __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
from utils import getFullDomain
from utils import getStatusNumber from utils import getStatusNumber
from utils import createOutboxDir from utils import createOutboxDir
from utils import urlPermitted from utils import urlPermitted
@ -113,11 +114,7 @@ def createAnnounce(session, baseDir: str, federationList: [],
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
newAnnounceId = httpPrefix + '://' + fullDomain + \ newAnnounceId = httpPrefix + '://' + fullDomain + \
@ -172,11 +169,7 @@ def announcePublic(session, baseDir: str, federationList: [],
debug: bool, projectVersion: str) -> {}: debug: bool, projectVersion: str) -> {}:
"""Makes a public announcement """Makes a public announcement
""" """
fromDomain = domain fromDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fromDomain = domain + ':' + str(port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \ ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \
@ -200,11 +193,7 @@ def repeatPost(session, baseDir: str, federationList: [],
debug: bool, projectVersion: str) -> {}: debug: bool, projectVersion: str) -> {}:
"""Repeats a given status post """Repeats a given status post
""" """
announcedDomain = announceDomain announcedDomain = getFullDomain(announceDomain, announcePort)
if announcePort:
if announcePort != 80 and announcePort != 443:
if ':' not in announcedDomain:
announcedDomain = announcedDomain + ':' + str(announcePort)
objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \ objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \
announceNickname + '/statuses/' + str(announceStatusNumber) announceNickname + '/statuses/' + str(announceStatusNumber)
@ -236,11 +225,7 @@ def undoAnnounce(session, baseDir: str, federationList: [],
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
newUndoAnnounce = { newUndoAnnounce = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -290,11 +275,7 @@ def undoAnnouncePublic(session, baseDir: str, federationList: [],
debug: bool) -> {}: debug: bool) -> {}:
"""Undoes a public announcement """Undoes a public announcement
""" """
fromDomain = domain fromDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fromDomain = domain + ':' + str(port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \ ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \
@ -318,11 +299,7 @@ def undoRepeatPost(session, baseDir: str, federationList: [],
debug: bool) -> {}: debug: bool) -> {}:
"""Undoes a status post repeat """Undoes a status post repeat
""" """
announcedDomain = announceDomain announcedDomain = getFullDomain(announceDomain, announcePort)
if announcePort:
if announcePort != 80 and announcePort != 443:
if ':' not in announcedDomain:
announcedDomain = announcedDomain + ':' + str(announcePort)
objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \ objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \
announceNickname + '/statuses/' + str(announceStatusNumber) announceNickname + '/statuses/' + str(announceStatusNumber)
@ -347,11 +324,7 @@ def sendAnnounceViaServer(baseDir: str, session,
print('WARN: No session for sendAnnounceViaServer') print('WARN: No session for sendAnnounceViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname + \ ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname + \

View File

@ -11,6 +11,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -85,11 +86,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
print('WARN: No session for sendAvailabilityViaServer') print('WARN: No session for sendAvailabilityViaServer')
return 6 return 6
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
toUrl = httpPrefix + '://' + domainFull + '/users/' + nickname toUrl = httpPrefix + '://' + domainFull + '/users/' + nickname
ccUrl = httpPrefix + '://' + domainFull + '/users/' + nickname + \ ccUrl = httpPrefix + '://' + domainFull + '/users/' + nickname + \

View File

@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
import os import os
from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import isEvil from utils import isEvil
from utils import locatePost from utils import locatePost
@ -265,11 +266,7 @@ def outboxBlock(baseDir: str, httpPrefix: str,
print('WARN: unable to find nickname in ' + messageJson['object']) print('WARN: unable to find nickname in ' + messageJson['object'])
return return
domainBlocked, portBlocked = getDomainFromActor(messageJson['object']) domainBlocked, portBlocked = getDomainFromActor(messageJson['object'])
domainBlockedFull = domainBlocked domainBlockedFull = getFullDomain(domainBlocked, portBlocked)
if portBlocked:
if portBlocked != 80 and portBlocked != 443:
if ':' not in domainBlocked:
domainBlockedFull = domainBlocked + ':' + str(portBlocked)
addBlock(baseDir, nickname, domain, addBlock(baseDir, nickname, domain,
nicknameBlocked, domainBlockedFull) nicknameBlocked, domainBlockedFull)
@ -346,11 +343,7 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str,
return return
domainObject = messageJson['object']['object'] domainObject = messageJson['object']['object']
domainBlocked, portBlocked = getDomainFromActor(domainObject) domainBlocked, portBlocked = getDomainFromActor(domainObject)
domainBlockedFull = domainBlocked domainBlockedFull = getFullDomain(domainBlocked, portBlocked)
if portBlocked:
if portBlocked != 80 and portBlocked != 443:
if ':' not in domainBlocked:
domainBlockedFull = domainBlocked + ':' + str(portBlocked)
removeBlock(baseDir, nickname, domain, removeBlock(baseDir, nickname, domain,
nicknameBlocked, domainBlockedFull) nicknameBlocked, domainBlockedFull)

21
blog.py
View File

@ -14,6 +14,7 @@ from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter from webapp_utils import htmlFooter
from webapp_utils import getPostAttachmentsAsHtml from webapp_utils import getPostAttachmentsAsHtml
from webapp_media import addEmbeddedElements from webapp_media import addEmbeddedElements
from utils import getFullDomain
from utils import getMediaFormats from utils import getMediaFormats
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -443,10 +444,7 @@ def htmlBlogPage(authorized: bool, session,
if not timelineJson: if not timelineJson:
return blogStr + htmlFooter() return blogStr + htmlFooter()
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
# show previous and next buttons # show previous and next buttons
if pageNumber is not None: if pageNumber is not None:
@ -513,10 +511,7 @@ def htmlBlogPageRSS2(authorized: bool, session,
'\n' in nickname or '\r' in nickname: '\n' in nickname or '\r' in nickname:
return None return None
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
blogRSS2 = '' blogRSS2 = ''
if includeHeader: if includeHeader:
@ -571,10 +566,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 = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
blogRSS3 = '' blogRSS3 = ''
@ -682,10 +674,7 @@ def htmlBlogView(authorized: bool,
nickname, domain, port, nickname, domain, port,
noOfItems, 1) noOfItems, 1)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
for subdir, dirs, files in os.walk(baseDir + '/accounts'): for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for acct in dirs: for acct in dirs:

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from pprint import pprint from pprint import pprint
from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import removePostFromCache from utils import removePostFromCache
from utils import urlPermitted from utils import urlPermitted
@ -237,11 +238,7 @@ def bookmark(recentPostsCache: {},
if not urlPermitted(objectUrl, federationList): if not urlPermitted(objectUrl, federationList):
return None return None
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
newBookmarkJson = { newBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -298,11 +295,7 @@ def bookmarkPost(recentPostsCache: {},
debug: bool, projectVersion: str) -> {}: debug: bool, projectVersion: str) -> {}:
"""Bookmarks a given status post. This is only used by unit tests """Bookmarks a given status post. This is only used by unit tests
""" """
bookmarkedomain = bookmarkedomain bookmarkedomain = getFullDomain(bookmarkedomain, bookmarkPort)
if bookmarkPort:
if bookmarkPort != 80 and bookmarkPort != 443:
if ':' not in bookmarkedomain:
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
actorBookmarked = httpPrefix + '://' + bookmarkedomain + \ actorBookmarked = httpPrefix + '://' + bookmarkedomain + \
'/users/' + bookmarkNickname '/users/' + bookmarkNickname
@ -333,11 +326,7 @@ def undoBookmark(recentPostsCache: {},
if not urlPermitted(objectUrl, federationList): if not urlPermitted(objectUrl, federationList):
return None return None
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
newUndoBookmarkJson = { newUndoBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -396,11 +385,7 @@ def undoBookmarkPost(session, baseDir: str, federationList: [],
debug: bool) -> {}: debug: bool) -> {}:
"""Removes a bookmarked post """Removes a bookmarked post
""" """
bookmarkedomain = bookmarkedomain bookmarkedomain = getFullDomain(bookmarkedomain, bookmarkPort)
if bookmarkPort:
if bookmarkPort != 80 and bookmarkPort != 443:
if ':' not in bookmarkedomain:
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
objectUrl = httpPrefix + '://' + bookmarkedomain + \ objectUrl = httpPrefix + '://' + bookmarkedomain + \
'/users/' + bookmarkNickname + \ '/users/' + bookmarkNickname + \
@ -425,11 +410,7 @@ def sendBookmarkViaServer(baseDir: str, session,
print('WARN: No session for sendBookmarkViaServer') print('WARN: No session for sendBookmarkViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
newBookmarkJson = { newBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -503,11 +484,7 @@ def sendUndoBookmarkViaServer(baseDir: str, session,
print('WARN: No session for sendUndoBookmarkViaServer') print('WARN: No session for sendUndoBookmarkViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
newUndoBookmarkJson = { newUndoBookmarkJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",

239
daemon.py
View File

@ -172,6 +172,7 @@ from shares import getSharesFeedForPerson
from shares import addShare from shares import addShare
from shares import removeShare from shares import removeShare
from shares import expireShares from shares import expireShares
from utils import getFullDomain
from utils import removeHtml from utils import removeHtml
from utils import setHashtagCategory from utils import setHashtagCategory
from utils import isEditor from utils import isEditor
@ -1404,12 +1405,21 @@ class PubServer(BaseHTTPRequestHandler):
domain: str, domainFull: str, port: int, domain: str, domainFull: str, port: int,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
debug: bool) -> None: debug: bool) -> None:
"""Actions on the moderator screeen """Actions on the moderator screen
""" """
usersPath = path.replace('/moderationaction', '') usersPath = path.replace('/moderationaction', '')
nickname = usersPath.replace('/users/', '') nickname = usersPath.replace('/users/', '')
actorStr = httpPrefix + '://' + domainFull + usersPath if not isModerator(self.server.baseDir, nickname):
if callingDomain.endswith('.onion') and onionDomain:
actorStr = 'http://' + onionDomain + usersPath
elif (callingDomain.endswith('.i2p') and i2pDomain):
actorStr = 'http://' + i2pDomain + usersPath
self._redirect_headers(actorStr + '/moderation',
cookie, callingDomain)
self.server.POSTbusy = False
return
actorStr = httpPrefix + '://' + domainFull + usersPath
length = int(self.headers['Content-length']) length = int(self.headers['Content-length'])
try: try:
@ -1446,8 +1456,30 @@ class PubServer(BaseHTTPRequestHandler):
elif moderationStr.startswith('submitInfo'): elif moderationStr.startswith('submitInfo'):
searchHandle = moderationText searchHandle = moderationText
if searchHandle: if searchHandle:
if '/@' in searchHandle:
searchNickname = \
getNicknameFromActor(searchHandle)
searchDomain, searchPort = \
getDomainFromActor(searchHandle)
searchHandle = \
searchNickname + '@' + searchDomain
if '@' not in searchHandle: if '@' not in searchHandle:
searchHandle = None if searchHandle.startswith('http'):
searchNickname = \
getNicknameFromActor(searchHandle)
searchDomain, searchPort = \
getDomainFromActor(searchHandle)
searchHandle = \
searchNickname + '@' + searchDomain
if '@' not in searchHandle:
# is this a local nickname on this instance?
localHandle = \
searchHandle + '@' + self.server.domain
if os.path.isdir(self.server.baseDir +
'/accounts/' + localHandle):
searchHandle = localHandle
else:
searchHandle = None
if searchHandle: if searchHandle:
msg = \ msg = \
htmlAccountInfo(self.server.cssCache, htmlAccountInfo(self.server.cssCache,
@ -1501,12 +1533,7 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain # https://domain
blockDomain, blockPort = \ blockDomain, blockPort = \
getDomainFromActor(moderationText) getDomainFromActor(moderationText)
fullBlockDomain = blockDomain fullBlockDomain = getFullDomain(blockDomain, blockPort)
if blockPort:
if blockPort != 80 and blockPort != 443:
if ':' not in blockDomain:
fullBlockDomain = \
blockDomain + ':' + str(blockPort)
if '@' in moderationText: if '@' in moderationText:
# nick@domain or *@domain # nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1] fullBlockDomain = moderationText.split('@')[1]
@ -1524,12 +1551,7 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain # https://domain
blockDomain, blockPort = \ blockDomain, blockPort = \
getDomainFromActor(moderationText) getDomainFromActor(moderationText)
fullBlockDomain = blockDomain fullBlockDomain = getFullDomain(blockDomain, blockPort)
if blockPort:
if blockPort != 80 and blockPort != 443:
if ':' not in blockDomain:
fullBlockDomain = \
blockDomain + ':' + str(blockPort)
if '@' in moderationText: if '@' in moderationText:
# nick@domain or *@domain # nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1] fullBlockDomain = moderationText.split('@')[1]
@ -1692,12 +1714,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
optionsDomain, optionsPort = getDomainFromActor(optionsActor) optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = optionsDomain optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
if ':' not in optionsDomain:
optionsDomainFull = optionsDomain + ':' + \
str(optionsPort)
if chooserNickname == optionsNickname and \ if chooserNickname == optionsNickname and \
optionsDomain == domain and \ optionsDomain == domain and \
optionsPort == port: optionsPort == port:
@ -1780,23 +1797,61 @@ class PubServer(BaseHTTPRequestHandler):
# person options screen, permission to post to newswire # person options screen, permission to post to newswire
# See htmlPersonOptions # See htmlPersonOptions
if '&submitPostToNews=' in optionsConfirmParams: if '&submitPostToNews=' in optionsConfirmParams:
if isModerator(self.server.baseDir, chooserNickname): adminNickname = getConfigParam(self.server.baseDir, 'admin')
if (chooserNickname != optionsNickname and
(chooserNickname == adminNickname or
(isModerator(self.server.baseDir, chooserNickname) and
not isModerator(self.server.baseDir, optionsNickname)))):
postsToNews = None postsToNews = None
if 'postsToNews=' in optionsConfirmParams: if 'postsToNews=' in optionsConfirmParams:
postsToNews = optionsConfirmParams.split('postsToNews=')[1] postsToNews = optionsConfirmParams.split('postsToNews=')[1]
if '&' in postsToNews: if '&' in postsToNews:
postsToNews = postsToNews.split('&')[0] postsToNews = postsToNews.split('&')[0]
newswireBlockedFilename = \ accountDir = self.server.baseDir + '/accounts/' + \
self.server.baseDir + '/accounts/' + \ optionsNickname + '@' + optionsDomain
optionsNickname + '@' + optionsDomain + '/.nonewswire' newswireBlockedFilename = accountDir + '/.nonewswire'
if postsToNews == 'on': if postsToNews == 'on':
if os.path.isfile(newswireBlockedFilename): if os.path.isfile(newswireBlockedFilename):
os.remove(newswireBlockedFilename) os.remove(newswireBlockedFilename)
else: else:
noNewswireFile = open(newswireBlockedFilename, "w+") if os.path.isdir(accountDir):
if noNewswireFile: noNewswireFile = open(newswireBlockedFilename, "w+")
noNewswireFile.write('\n') if noNewswireFile:
noNewswireFile.close() noNewswireFile.write('\n')
noNewswireFile.close()
self._redirect_headers(usersPath + '/' +
self.server.defaultTimeline +
'?page='+str(pageNumber), cookie,
callingDomain)
self.server.POSTbusy = False
return
# person options screen, permission to post to newswire
# See htmlPersonOptions
if '&submitModNewsPosts=' in optionsConfirmParams:
adminNickname = getConfigParam(self.server.baseDir, 'admin')
if (chooserNickname != optionsNickname and
(chooserNickname == adminNickname or
(isModerator(self.server.baseDir, chooserNickname) and
not isModerator(self.server.baseDir, optionsNickname)))):
modPostsToNews = None
if 'modNewsPosts=' in optionsConfirmParams:
modPostsToNews = \
optionsConfirmParams.split('modNewsPosts=')[1]
if '&' in modPostsToNews:
modPostsToNews = modPostsToNews.split('&')[0]
accountDir = self.server.baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain
newswireModFilename = accountDir + '/.newswiremoderated'
if modPostsToNews != 'on':
if os.path.isfile(newswireModFilename):
os.remove(newswireModFilename)
else:
if os.path.isdir(accountDir):
modNewswireFile = open(newswireModFilename, "w+")
if modNewswireFile:
modNewswireFile.write('\n')
modNewswireFile.close()
self._redirect_headers(usersPath + '/' + self._redirect_headers(usersPath + '/' +
self.server.defaultTimeline + self.server.defaultTimeline +
'?page='+str(pageNumber), cookie, '?page='+str(pageNumber), cookie,
@ -1891,6 +1946,31 @@ class PubServer(BaseHTTPRequestHandler):
self.server.POSTbusy = False self.server.POSTbusy = False
return return
# person options screen, Info button
# See htmlPersonOptions
if '&submitPersonInfo=' in optionsConfirmParams:
if isModerator(self.server.baseDir, chooserNickname):
if debug:
print('Showing info for ' + optionsActor)
msg = \
htmlAccountInfo(self.server.cssCache,
self.server.translate,
baseDir,
httpPrefix,
chooserNickname,
domain,
self.server.port,
optionsActor,
self.server.debug).encode('utf-8')
self._set_headers('text/html', len(msg),
cookie, callingDomain)
self._write(msg)
self.server.POSTbusy = False
return
else:
self._404()
return
# person options screen, snooze button # person options screen, snooze button
# See htmlPersonOptions # See htmlPersonOptions
if '&submitSnooze=' in optionsConfirmParams: if '&submitSnooze=' in optionsConfirmParams:
@ -2011,11 +2091,7 @@ class PubServer(BaseHTTPRequestHandler):
followingNickname = getNicknameFromActor(followingActor) followingNickname = getNicknameFromActor(followingActor)
followingDomain, followingPort = \ followingDomain, followingPort = \
getDomainFromActor(followingActor) getDomainFromActor(followingActor)
followingDomainFull = followingDomain followingDomainFull = getFullDomain(followingDomain, followingPort)
if followingPort:
if followingPort != 80 and followingPort != 443:
followingDomainFull = \
followingDomain + ':' + str(followingPort)
if followerNickname == followingNickname and \ if followerNickname == followingNickname and \
followingDomain == domain and \ followingDomain == domain and \
followingPort == port: followingPort == port:
@ -2208,12 +2284,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
blockingDomain, blockingPort = \ blockingDomain, blockingPort = \
getDomainFromActor(blockingActor) getDomainFromActor(blockingActor)
blockingDomainFull = blockingDomain blockingDomainFull = getFullDomain(blockingDomain, blockingPort)
if blockingPort:
if blockingPort != 80 and blockingPort != 443:
if ':' not in blockingDomain:
blockingDomainFull = \
blockingDomain + ':' + str(blockingPort)
if blockerNickname == blockingNickname and \ if blockerNickname == blockingNickname and \
blockingDomain == domain and \ blockingDomain == domain and \
blockingPort == port: blockingPort == port:
@ -2297,12 +2368,7 @@ class PubServer(BaseHTTPRequestHandler):
return return
blockingDomain, blockingPort = \ blockingDomain, blockingPort = \
getDomainFromActor(blockingActor) getDomainFromActor(blockingActor)
blockingDomainFull = blockingDomain blockingDomainFull = getFullDomain(blockingDomain, blockingPort)
if blockingPort:
if blockingPort != 80 and blockingPort != 443:
if ':' not in blockingDomain:
blockingDomainFull = \
blockingDomain + ':' + str(blockingPort)
if blockerNickname == blockingNickname and \ if blockerNickname == blockingNickname and \
blockingDomain == domain and \ blockingDomain == domain and \
blockingPort == port: blockingPort == port:
@ -3701,6 +3767,11 @@ class PubServer(BaseHTTPRequestHandler):
if os.path.isfile(actorFilename): if os.path.isfile(actorFilename):
actorJson = loadJson(actorFilename) actorJson = loadJson(actorFilename)
if actorJson: if actorJson:
if not actorJson.get('discoverable'):
# discoverable in profile directory
# which isn't implemented in Epicyon
actorJson['discoverable'] = False
actorChanged = True
# update the avatar/image url file extension # update the avatar/image url file extension
uploads = profileMediaTypesUploaded.items() uploads = profileMediaTypesUploaded.items()
for mType, lastPart in uploads: for mType, lastPart in uploads:
@ -3712,6 +3783,13 @@ class PubServer(BaseHTTPRequestHandler):
actorJson['icon']['url'] = \ actorJson['icon']['url'] = \
actorJson['icon']['url'].replace(srchStr, actorJson['icon']['url'].replace(srchStr,
repStr) repStr)
if '.' in actorJson['icon']['url']:
imgExt = \
actorJson['icon']['url'].split('.')[-1]
if imgExt == 'jpg':
imgExt = 'jpeg'
actorJson['icon']['mediaType'] = \
'image/' + imgExt
elif mType == 'image': elif mType == 'image':
lastPartOfUrl = \ lastPartOfUrl = \
actorJson['image']['url'].split('/')[-1] actorJson['image']['url'].split('/')[-1]
@ -3719,6 +3797,13 @@ class PubServer(BaseHTTPRequestHandler):
actorJson['image']['url'] = \ actorJson['image']['url'] = \
actorJson['image']['url'].replace(srchStr, actorJson['image']['url'].replace(srchStr,
repStr) repStr)
if '.' in actorJson['image']['url']:
imgExt = \
actorJson['image']['url'].split('.')[-1]
if imgExt == 'jpg':
imgExt = 'jpeg'
actorJson['image']['mediaType'] = \
'image/' + imgExt
# set skill levels # set skill levels
skillCtr = 1 skillCtr = 1
@ -4451,15 +4536,23 @@ class PubServer(BaseHTTPRequestHandler):
actorJson['id'].replace('/', '#') + '.json' actorJson['id'].replace('/', '#') + '.json'
saveJson(actorJson, actorCacheFilename) saveJson(actorJson, actorCacheFilename)
# send profile update to followers # send profile update to followers
ccStr = 'https://www.w3.org/ns/' + \ pubStr = 'https://www.w3.org/ns/' + \
'activitystreams#Public' 'activitystreams#Public'
pubNumber, pubDate = getStatusNumber()
pubContext = actorJson['@context'].copy()
# remove the context from the actor json and put it
# at the start of the Upgrade activity
del actorJson['@context']
updateActorJson = { updateActorJson = {
'@context': pubContext,
'id': actorJson['id'] + '#updates/' + pubNumber,
'type': 'Update', 'type': 'Update',
'actor': actorJson['id'], 'actor': actorJson['id'],
'to': [actorJson['id'] + '/followers'], 'to': [pubStr],
'cc': [ccStr], 'cc': [actorJson['id'] + '/followers'],
'object': actorJson 'object': actorJson
} }
print('Sending actor update: ' + str(updateActorJson))
self._postToOutbox(updateActorJson, self._postToOutbox(updateActorJson,
__version__, nickname) __version__, nickname)
@ -5531,15 +5624,22 @@ class PubServer(BaseHTTPRequestHandler):
""" """
originPathStr = path.split('/newswirevote=')[0] originPathStr = path.split('/newswirevote=')[0]
dateStr = \ dateStr = \
path.split('/newswirevote=')[1].replace('T', ' ') + '+00:00' path.split('/newswirevote=')[1].replace('T', ' ')
nickname = originPathStr.split('/users/')[1] dateStr = dateStr.replace(' 00:00', '').replace('+00:00', '')
dateStr = urllib.parse.unquote_plus(dateStr) + '+00:00'
nickname = urllib.parse.unquote_plus(originPathStr.split('/users/')[1])
if '/' in nickname: if '/' in nickname:
nickname = nickname.split('/')[0] nickname = nickname.split('/')[0]
print('Newswire item date: ' + dateStr)
if newswire.get(dateStr): if newswire.get(dateStr):
if isModerator(baseDir, nickname): if isModerator(baseDir, nickname):
if 'vote:' + nickname not in newswire[dateStr][2]: newswireItem = newswire[dateStr]
newswire[dateStr][2].append('vote:' + nickname) print('Voting on newswire item: ' + str(newswireItem))
filename = newswire[dateStr][3] votesIndex = 2
filenameIndex = 3
if 'vote:' + nickname not in newswireItem[votesIndex]:
newswireItem[votesIndex].append('vote:' + nickname)
filename = newswireItem[filenameIndex]
newswireStateFilename = \ newswireStateFilename = \
baseDir + '/accounts/.newswirestate.json' baseDir + '/accounts/.newswirestate.json'
try: try:
@ -5547,8 +5647,11 @@ class PubServer(BaseHTTPRequestHandler):
except Exception as e: except Exception as e:
print('ERROR saving newswire state, ' + str(e)) print('ERROR saving newswire state, ' + str(e))
if filename: if filename:
saveJson(newswire[dateStr][2], saveJson(newswireItem[votesIndex],
filename + '.votes') filename + '.votes')
else:
print('No newswire item with date: ' + dateStr + ' ' +
str(newswire))
originPathStrAbsolute = \ originPathStrAbsolute = \
httpPrefix + '://' + domainFull + originPathStr + '/' + \ httpPrefix + '://' + domainFull + originPathStr + '/' + \
@ -5578,15 +5681,20 @@ class PubServer(BaseHTTPRequestHandler):
""" """
originPathStr = path.split('/newswireunvote=')[0] originPathStr = path.split('/newswireunvote=')[0]
dateStr = \ dateStr = \
path.split('/newswireunvote=')[1].replace('T', ' ') + '+00:00' path.split('/newswireunvote=')[1].replace('T', ' ')
nickname = originPathStr.split('/users/')[1] dateStr = dateStr.replace(' 00:00', '').replace('+00:00', '')
dateStr = urllib.parse.unquote_plus(dateStr) + '+00:00'
nickname = urllib.parse.unquote_plus(originPathStr.split('/users/')[1])
if '/' in nickname: if '/' in nickname:
nickname = nickname.split('/')[0] nickname = nickname.split('/')[0]
if newswire.get(dateStr): if newswire.get(dateStr):
if isModerator(baseDir, nickname): if isModerator(baseDir, nickname):
if 'vote:' + nickname in newswire[dateStr][2]: votesIndex = 2
newswire[dateStr][2].remove('vote:' + nickname) filenameIndex = 3
filename = newswire[dateStr][3] newswireItem = newswire[dateStr]
if 'vote:' + nickname in newswireItem[votesIndex]:
newswireItem[votesIndex].remove('vote:' + nickname)
filename = newswireItem[filenameIndex]
newswireStateFilename = \ newswireStateFilename = \
baseDir + '/accounts/.newswirestate.json' baseDir + '/accounts/.newswirestate.json'
try: try:
@ -5594,8 +5702,11 @@ class PubServer(BaseHTTPRequestHandler):
except Exception as e: except Exception as e:
print('ERROR saving newswire state, ' + str(e)) print('ERROR saving newswire state, ' + str(e))
if filename: if filename:
saveJson(newswire[dateStr][2], saveJson(newswireItem[votesIndex],
filename + '.votes') filename + '.votes')
else:
print('No newswire item with date: ' + dateStr + ' ' +
str(newswire))
originPathStrAbsolute = \ originPathStrAbsolute = \
httpPrefix + '://' + domainFull + originPathStr + '/' + \ httpPrefix + '://' + domainFull + originPathStr + '/' + \
@ -13154,11 +13265,7 @@ def runDaemon(dormantMonths: int,
httpd.maxPostsInBox = 32000 httpd.maxPostsInBox = 32000
httpd.domain = domain httpd.domain = domain
httpd.port = port httpd.port = port
httpd.domainFull = domain httpd.domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
httpd.domainFull = domain + ':' + str(port)
saveDomainQrcode(baseDir, httpPrefix, httpd.domainFull) saveDomainQrcode(baseDir, httpPrefix, httpd.domainFull)
httpd.httpPrefix = httpPrefix httpd.httpPrefix = httpPrefix
httpd.debug = debug httpd.debug = debug

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from datetime import datetime from datetime import datetime
from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getStatusNumber from utils import getStatusNumber
from utils import urlPermitted from utils import urlPermitted
@ -42,10 +43,7 @@ def createDelete(session, baseDir: str, federationList: [],
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
fullDomain = domain fullDomain = domain
if port: fullDomain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
newDeleteId = \ newDeleteId = \
@ -100,11 +98,7 @@ def sendDeleteViaServer(baseDir: str, session,
print('WARN: No session for sendDeleteViaServer') print('WARN: No session for sendDeleteViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
actor = httpPrefix + '://' + fromDomainFull + \ actor = httpPrefix + '://' + fromDomainFull + \
'/users/' + fromNickname '/users/' + fromNickname
@ -181,11 +175,7 @@ def deletePublic(session, baseDir: str, federationList: [],
debug: bool) -> {}: debug: bool) -> {}:
"""Makes a public delete activity """Makes a public delete activity
""" """
fromDomain = domain fromDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fromDomain = domain + ':' + str(port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomain + \ ccUrl = httpPrefix + '://' + fromDomain + \
@ -209,11 +199,7 @@ def deletePostPub(session, baseDir: str, federationList: [],
debug: bool) -> {}: debug: bool) -> {}:
"""Deletes a given status post """Deletes a given status post
""" """
deletedDomain = deleteDomain deletedDomain = getFullDomain(deleteDomain, deletePort)
if deletePort:
if deletePort != 80 and deletePort != 443:
if ':' not in deletedDomain:
deletedDomain = deletedDomain + ':' + str(deletePort)
objectUrl = \ objectUrl = \
deleteHttpsPrefix + '://' + deletedDomain + '/users/' + \ deleteHttpsPrefix + '://' + deletedDomain + '/users/' + \

View File

@ -47,6 +47,7 @@ from tests import testClientToServer
from tests import runAllTests from tests import runAllTests
from auth import storeBasicCredentials from auth import storeBasicCredentials
from auth import createPassword from auth import createPassword
from utils import getFullDomain
from utils import setConfigParam from utils import setConfigParam
from utils import getConfigParam from utils import getConfigParam
from utils import getDomainFromActor from utils import getDomainFromActor
@ -501,10 +502,8 @@ if args.posts:
if '/users/' in args.posts: if '/users/' in args.posts:
postsNickname = getNicknameFromActor(args.posts) postsNickname = getNicknameFromActor(args.posts)
postsDomain, postsPort = getDomainFromActor(args.posts) postsDomain, postsPort = getDomainFromActor(args.posts)
args.posts = postsNickname + '@' + postsDomain args.posts = \
if postsPort: getFullDomain(postsNickname + '@' + postsDomain, postsPort)
if postsPort != 80 and postsPort != 443:
args.posts += ':' + str(postsPort)
else: else:
print('Syntax: --posts nickname@domain') print('Syntax: --posts nickname@domain')
sys.exit() sys.exit()
@ -533,10 +532,8 @@ if args.postDomains:
if '/users/' in args.postDomains: if '/users/' in args.postDomains:
postsNickname = getNicknameFromActor(args.postDomains) postsNickname = getNicknameFromActor(args.postDomains)
postsDomain, postsPort = getDomainFromActor(args.postDomains) postsDomain, postsPort = getDomainFromActor(args.postDomains)
args.postDomains = postsNickname + '@' + postsDomain args.postDomains = \
if postsPort: getFullDomain(postsNickname + '@' + postsDomain, postsPort)
if postsPort != 80 and postsPort != 443:
args.postDomains += ':' + str(postsPort)
else: else:
print('Syntax: --postDomains nickname@domain') print('Syntax: --postDomains nickname@domain')
sys.exit() sys.exit()
@ -573,10 +570,8 @@ if args.postDomainsBlocked:
postsNickname = getNicknameFromActor(args.postDomainsBlocked) postsNickname = getNicknameFromActor(args.postDomainsBlocked)
postsDomain, postsPort = \ postsDomain, postsPort = \
getDomainFromActor(args.postDomainsBlocked) getDomainFromActor(args.postDomainsBlocked)
args.postDomainsBlocked = postsNickname + '@' + postsDomain args.postDomainsBlocked = \
if postsPort: getFullDomain(postsNickname + '@' + postsDomain, postsPort)
if postsPort != 80 and postsPort != 443:
args.postDomainsBlocked += ':' + str(postsPort)
else: else:
print('Syntax: --postDomainsBlocked nickname@domain') print('Syntax: --postDomainsBlocked nickname@domain')
sys.exit() sys.exit()
@ -612,10 +607,8 @@ if args.checkDomains:
if '/users/' in args.checkDomains: if '/users/' in args.checkDomains:
postsNickname = getNicknameFromActor(args.posts) postsNickname = getNicknameFromActor(args.posts)
postsDomain, postsPort = getDomainFromActor(args.posts) postsDomain, postsPort = getDomainFromActor(args.posts)
args.checkDomains = postsNickname + '@' + postsDomain args.checkDomains = \
if postsPort: getFullDomain(postsNickname + '@' + postsDomain, postsPort)
if postsPort != 80 and postsPort != 443:
args.checkDomains += ':' + str(postsPort)
else: else:
print('Syntax: --checkDomains nickname@domain') print('Syntax: --checkDomains nickname@domain')
sys.exit() sys.exit()

View File

@ -8,6 +8,7 @@ __status__ = "Production"
from pprint import pprint from pprint import pprint
import os import os
from utils import getFullDomain
from utils import isSystemAccount from utils import isSystemAccount
from utils import getFollowersList from utils import getFollowersList
from utils import validNickname from utils import validNickname
@ -145,11 +146,8 @@ def isFollowingActor(baseDir: str,
print('WARN: unable to find nickname in ' + actor) print('WARN: unable to find nickname in ' + actor)
return False return False
followingDomain, followingPort = getDomainFromActor(actor) followingDomain, followingPort = getDomainFromActor(actor)
followingHandle = followingNickname + '@' + followingDomain followingHandle = \
if followingPort: getFullDomain(followingNickname + '@' + followingDomain, followingPort)
if followingPort != 80 and followingPort != 443:
if ':' not in followingHandle:
followingHandle += ':' + str(followingPort)
if followingHandle.lower() in open(followingFile).read().lower(): if followingHandle.lower() in open(followingFile).read().lower():
return True return True
return False return False
@ -374,10 +372,7 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str,
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
return None return None
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
if headerOnly: if headerOnly:
firstStr = \ firstStr = \
@ -539,12 +534,8 @@ def storeFollowRequest(baseDir: str,
return False return False
approveHandle = nickname + '@' + domain approveHandle = nickname + '@' + domain
domainFull = domain domainFull = getFullDomain(domain, fromPort)
if fromPort: approveHandle = getFullDomain(nickname + '@' + domain, fromPort)
if fromPort != 80 and fromPort != 443:
if ':' not in domain:
approveHandle = nickname + '@' + domain + ':' + str(fromPort)
domainFull = domain + ':' + str(fromPort)
followersFilename = accountsDir + '/followers.txt' followersFilename = accountsDir + '/followers.txt'
if os.path.isfile(followersFilename): if os.path.isfile(followersFilename):
@ -634,12 +625,9 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
return False return False
domain, tempPort = getDomainFromActor(messageJson['actor']) domain, tempPort = getDomainFromActor(messageJson['actor'])
fromPort = port fromPort = port
domainFull = domain domainFull = getFullDomain(domain, tempPort)
if tempPort: if tempPort:
fromPort = tempPort fromPort = tempPort
if tempPort != 80 and tempPort != 443:
if ':' not in domain:
domainFull = domain + ':' + str(tempPort)
if not domainPermitted(domain, federationList): if not domainPermitted(domain, federationList):
if debug: if debug:
print('DEBUG: follower from domain not permitted - ' + domain) print('DEBUG: follower from domain not permitted - ' + domain)
@ -666,11 +654,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
if debug: if debug:
print('DEBUG: follow domain not permitted ' + domainToFollow) print('DEBUG: follow domain not permitted ' + domainToFollow)
return True return True
domainToFollowFull = domainToFollow domainToFollowFull = getFullDomain(domainToFollow, tempPort)
if tempPort:
if tempPort != 80 and tempPort != 443:
if ':' not in domainToFollow:
domainToFollowFull = domainToFollow + ':' + str(tempPort)
nicknameToFollow = getNicknameFromActor(messageJson['object']) nicknameToFollow = getNicknameFromActor(messageJson['object'])
if not nicknameToFollow: if not nicknameToFollow:
if debug: if debug:
@ -878,10 +862,7 @@ def followedAccountRejects(session, baseDir: str, httpPrefix: str,
' port ' + str(port) + ' to ' + ' port ' + str(port) + ' to ' +
nickname + '@' + domain + ' port ' + str(fromPort)) nickname + '@' + domain + ' port ' + str(fromPort))
clientToServer = False clientToServer = False
denyHandle = nickname + '@' + domain denyHandle = getFullDomain(nickname + '@' + domain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
denyHandle = denyHandle + ':' + str(fromPort)
# remove from the follow requests file # remove from the follow requests file
removeFromFollowRequests(baseDir, nicknameToFollow, domainToFollow, removeFromFollowRequests(baseDir, nicknameToFollow, domainToFollow,
denyHandle, debug) denyHandle, debug)
@ -913,20 +894,10 @@ def sendFollowRequest(session, baseDir: str,
if not domainPermitted(followDomain, federationList): if not domainPermitted(followDomain, federationList):
return None return None
fullDomain = domain fullDomain = getFullDomain(domain, port)
followActor = httpPrefix + '://' + domain + '/users/' + nickname followActor = httpPrefix + '://' + fullDomain + '/users/' + nickname
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
followActor = httpPrefix + '://' + \
fullDomain + '/users/' + nickname
requestDomain = followDomain requestDomain = getFullDomain(followDomain, followPort)
if followPort:
if followPort != 80 and followPort != 443:
if ':' not in followDomain:
requestDomain = followDomain + ':' + str(followPort)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
@ -984,17 +955,9 @@ def sendFollowRequestViaServer(baseDir: str, session,
print('WARN: No session for sendFollowRequestViaServer') print('WARN: No session for sendFollowRequestViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
followDomainFull = followDomain followDomainFull = getFullDomain(followDomain, followPort)
if followPort:
if followPort != 80 and followPort != 443:
if ':' not in followDomain:
followDomainFull = followDomain + ':' + str(followPort)
followActor = httpPrefix + '://' + \ followActor = httpPrefix + '://' + \
fromDomainFull + '/users/' + fromNickname fromDomainFull + '/users/' + fromNickname
@ -1077,16 +1040,8 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
print('WARN: No session for sendUnfollowRequestViaServer') print('WARN: No session for sendUnfollowRequestViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort: followDomainFull = getFullDomain(followDomain, followPort)
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
followDomainFull = followDomain
if followPort:
if followPort != 80 and followPort != 443:
if ':' not in followDomain:
followDomainFull = followDomain + ':' + str(followPort)
followActor = httpPrefix + '://' + \ followActor = httpPrefix + '://' + \
fromDomainFull + '/users/' + fromNickname fromDomainFull + '/users/' + fromNickname
@ -1241,11 +1196,7 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None:
return return
domainFollower, portFollower = \ domainFollower, portFollower = \
getDomainFromActor(messageJson['object']['actor']) getDomainFromActor(messageJson['object']['actor'])
domainFollowerFull = domainFollower domainFollowerFull = getFullDomain(domainFollower, portFollower)
if portFollower:
if portFollower != 80 and portFollower != 443:
if ':' not in domainFollower:
domainFollowerFull = domainFollower + ':' + str(portFollower)
nicknameFollowing = getNicknameFromActor(messageJson['object']['object']) nicknameFollowing = getNicknameFromActor(messageJson['object']['object'])
if not nicknameFollowing: if not nicknameFollowing:
@ -1254,12 +1205,7 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None:
return return
domainFollowing, portFollowing = \ domainFollowing, portFollowing = \
getDomainFromActor(messageJson['object']['object']) getDomainFromActor(messageJson['object']['object'])
domainFollowingFull = domainFollowing domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
if portFollowing:
if portFollowing != 80 and portFollowing != 443:
if ':' not in domainFollowing:
domainFollowingFull = \
domainFollowing + ':' + str(portFollowing)
if unfollowPerson(baseDir, nicknameFollower, domainFollowerFull, if unfollowPerson(baseDir, nicknameFollower, domainFollowerFull,
nicknameFollowing, domainFollowingFull): nicknameFollowing, domainFollowingFull):

View File

@ -22,6 +22,7 @@ except ImportError:
import base64 import base64
from time import gmtime, strftime from time import gmtime, strftime
import datetime import datetime
from utils import getFullDomain
def messageContentDigest(messageBodyJsonStr: str) -> str: def messageContentDigest(messageBodyJsonStr: str) -> str:
@ -40,15 +41,9 @@ def signPostHeaders(dateStr: str, privateKeyPem: str,
"""Returns a raw signature string that can be plugged into a header and """Returns a raw signature string that can be plugged into a header and
used to verify the authenticity of an HTTP transmission. used to verify the authenticity of an HTTP transmission.
""" """
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
if toPort: toDomain = getFullDomain(toDomain, toPort)
if toPort != 80 and toPort != 443:
if ':' not in toDomain:
toDomain = toDomain + ':' + str(port)
if not dateStr: if not dateStr:
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
@ -107,12 +102,7 @@ def createSignedHeader(privateKeyPem: str, nickname: str,
"""Note that the domain is the destination, not the sender """Note that the domain is the destination, not the sender
""" """
contentType = 'application/activity+json' contentType = 'application/activity+json'
headerDomain = toDomain headerDomain = getFullDomain(toDomain, toPort)
if toPort:
if toPort != 80 and toPort != 443:
if ':' not in headerDomain:
headerDomain = headerDomain + ':' + str(toPort)
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
if not withDigest: if not withDigest:

View File

@ -10,6 +10,7 @@ import json
import os import os
import datetime import datetime
import time import time
from utils import getFullDomain
from utils import isEventPost from utils import isEventPost
from utils import removeIdEnding from utils import removeIdEnding
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
@ -371,10 +372,7 @@ def savePostToInboxQueue(baseDir: str, httpPrefix: str,
if debug: if debug:
print('DEBUG: post from ' + postNickname + ' blocked') print('DEBUG: post from ' + postNickname + ' blocked')
return None return None
if postPort: postDomain = getFullDomain(postDomain, postPort)
if postPort != 80 and postPort != 443:
if ':' not in postDomain:
postDomain = postDomain + ':' + str(postPort)
if postJsonObject.get('object'): if postJsonObject.get('object'):
if isinstance(postJsonObject['object'], dict): if isinstance(postJsonObject['object'], dict):
@ -524,10 +522,7 @@ def inboxPostRecipients(baseDir: str, postJsonObject: {},
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
domainBase = domain domainBase = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
domainMatch = '/' + domain + '/users/' domainMatch = '/' + domain + '/users/'
actor = postJsonObject['actor'] actor = postJsonObject['actor']
@ -649,11 +644,7 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str,
return False return False
domainFollower, portFollower = \ domainFollower, portFollower = \
getDomainFromActor(messageJson['object']['actor']) getDomainFromActor(messageJson['object']['actor'])
domainFollowerFull = domainFollower domainFollowerFull = getFullDomain(domainFollower, portFollower)
if portFollower:
if portFollower != 80 and portFollower != 443:
if ':' not in domainFollower:
domainFollowerFull = domainFollower + ':' + str(portFollower)
nicknameFollowing = \ nicknameFollowing = \
getNicknameFromActor(messageJson['object']['object']) getNicknameFromActor(messageJson['object']['object'])
@ -663,12 +654,7 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str,
return False return False
domainFollowing, portFollowing = \ domainFollowing, portFollowing = \
getDomainFromActor(messageJson['object']['object']) getDomainFromActor(messageJson['object']['object'])
domainFollowingFull = domainFollowing domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
if portFollowing:
if portFollowing != 80 and portFollowing != 443:
if ':' not in domainFollowing:
domainFollowingFull = \
domainFollowing + ':' + str(portFollowing)
if unfollowerOfPerson(baseDir, if unfollowerOfPerson(baseDir,
nicknameFollowing, domainFollowingFull, nicknameFollowing, domainFollowingFull,
@ -749,10 +735,7 @@ def receiveEventPost(recentPostsCache: {}, session, baseDir: str,
if not isEventPost(messageJson): if not isEventPost(messageJson):
return return
print('Receiving event: ' + str(messageJson['object'])) print('Receiving event: ' + str(messageJson['object']))
handle = nickname + '@' + domain handle = getFullDomain(nickname + '@' + domain, port)
if port:
if port != 80 and port != 443:
handle += ':' + str(port)
postId = removeIdEnding(messageJson['id']).replace('/', '#') postId = removeIdEnding(messageJson['id']).replace('/', '#')
@ -766,16 +749,10 @@ def personReceiveUpdate(baseDir: str,
personJson: {}, personCache: {}, debug: bool) -> bool: personJson: {}, personCache: {}, debug: bool) -> bool:
"""Changes an actor. eg: avatar or display name change """Changes an actor. eg: avatar or display name change
""" """
if debug: print('Receiving actor update for ' + personJson['url'] +
print('DEBUG: receiving actor update for ' + personJson['url']) ' ' + str(personJson))
domainFull = domain domainFull = getFullDomain(domain, port)
if port: updateDomainFull = getFullDomain(updateDomain, updatePort)
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
updateDomainFull = updateDomain
if updatePort:
if updatePort != 80 and updatePort != 443:
updateDomainFull = updateDomain + ':' + str(updatePort)
actor = updateDomainFull + '/users/' + updateNickname actor = updateDomainFull + '/users/' + updateNickname
if actor not in personJson['id']: if actor not in personJson['id']:
actor = updateDomainFull + '/profile/' + updateNickname actor = updateDomainFull + '/profile/' + updateNickname
@ -917,7 +894,7 @@ def receiveUpdate(recentPostsCache: {}, session, baseDir: str,
if messageJson['type'] == 'Person': if messageJson['type'] == 'Person':
if messageJson.get('url') and messageJson.get('id'): if messageJson.get('url') and messageJson.get('id'):
print('Request to update unwrapped actor: ' + messageJson['id']) print('Request to update actor unwrapped: ' + str(messageJson))
updateNickname = getNicknameFromActor(messageJson['id']) updateNickname = getNicknameFromActor(messageJson['id'])
if updateNickname: if updateNickname:
updateDomain, updatePort = \ updateDomain, updatePort = \
@ -938,7 +915,7 @@ def receiveUpdate(recentPostsCache: {}, session, baseDir: str,
messageJson['object']['type'] == 'Service': messageJson['object']['type'] == 'Service':
if messageJson['object'].get('url') and \ if messageJson['object'].get('url') and \
messageJson['object'].get('id'): messageJson['object'].get('id'):
print('Request to update actor: ' + messageJson['actor']) print('Request to update actor: ' + str(messageJson))
updateNickname = getNicknameFromActor(messageJson['actor']) updateNickname = getNicknameFromActor(messageJson['actor'])
if updateNickname: if updateNickname:
updateDomain, updatePort = \ updateDomain, updatePort = \
@ -1124,10 +1101,7 @@ def receiveBookmark(recentPostsCache: {},
if debug: if debug:
print('DEBUG: unrecognized domain ' + handle) print('DEBUG: unrecognized domain ' + handle)
return False return False
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if not messageJson['actor'].endswith(domainFull + '/users/' + nickname): if not messageJson['actor'].endswith(domainFull + '/users/' + nickname):
if debug: if debug:
@ -1192,10 +1166,7 @@ def receiveUndoBookmark(recentPostsCache: {},
print('DEBUG: "statuses" missing from like object in ' + print('DEBUG: "statuses" missing from like object in ' +
messageJson['type']) messageJson['type'])
return False return False
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
if domain not in handle.split('@')[1]: if domain not in handle.split('@')[1]:
if debug: if debug:
@ -1249,11 +1220,7 @@ def receiveDelete(session, handle: str, isGroup: bool, baseDir: str,
if debug: if debug:
print('DEBUG: ' + messageJson['type'] + ' object is not a string') print('DEBUG: ' + messageJson['type'] + ' object is not a string')
return False return False
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
deletePrefix = httpPrefix + '://' + domainFull + '/' deletePrefix = httpPrefix + '://' + domainFull + '/'
if (not allowDeletion and if (not allowDeletion and
(not messageJson['object'].startswith(deletePrefix) or (not messageJson['object'].startswith(deletePrefix) or
@ -1923,23 +1890,15 @@ def sendToGroupMembers(session, baseDir: str, handle: str, port: int,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
# groupname = getGroupName(baseDir, handle) # groupname = getGroupName(baseDir, handle)
domain = handle.split('@')[1] domain = handle.split('@')[1]
domainFull = domain domainFull = getFullDomain(domain, port)
if ':' not in domain:
if port:
if port != 80 and port != 443:
domain = domain + ':' + str(port)
# set sender # set sender
cc = '' cc = ''
sendingActor = postJsonObject['actor'] sendingActor = postJsonObject['actor']
sendingActorNickname = getNicknameFromActor(sendingActor) sendingActorNickname = getNicknameFromActor(sendingActor)
sendingActorDomain, sendingActorPort = \ sendingActorDomain, sendingActorPort = \
getDomainFromActor(sendingActor) getDomainFromActor(sendingActor)
sendingActorDomainFull = sendingActorDomain sendingActorDomainFull = \
if ':' in sendingActorDomain: getFullDomain(sendingActorDomain, sendingActorPort)
if sendingActorPort:
if sendingActorPort != 80 and sendingActorPort != 443:
sendingActorDomainFull = \
sendingActorDomain + ':' + str(sendingActorPort)
senderStr = '@' + sendingActorNickname + '@' + sendingActorDomainFull senderStr = '@' + sendingActorNickname + '@' + sendingActorDomainFull
if not postJsonObject['object']['content'].startswith(senderStr): if not postJsonObject['object']['content'].startswith(senderStr):
postJsonObject['object']['content'] = \ postJsonObject['object']['content'] = \
@ -2259,9 +2218,7 @@ def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
if isinstance(attributedTo, str): if isinstance(attributedTo, str):
fromNickname = getNicknameFromActor(attributedTo) fromNickname = getNicknameFromActor(attributedTo)
fromDomain, fromPort = getDomainFromActor(attributedTo) fromDomain, fromPort = getDomainFromActor(attributedTo)
if fromPort: fromDomain = getFullDomain(fromDomain, fromPort)
if fromPort != 80 and fromPort != 443:
fromDomain += ':' + str(fromPort)
if receiveGitPatch(baseDir, nickname, domain, if receiveGitPatch(baseDir, nickname, domain,
jsonObj['type'], jsonObj['type'],
jsonObj['summary'], jsonObj['summary'],
@ -2352,11 +2309,7 @@ def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
nickname + '/dm') nickname + '/dm')
# get the actor being replied to # get the actor being replied to
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if ':' not in domain:
if port != 80 and port != 443:
domainFull = domainFull + ':' + str(port)
actor = httpPrefix + '://' + domainFull + \ actor = httpPrefix + '://' + domainFull + \
'/users/' + handle.split('@')[0] '/users/' + handle.split('@')[0]

31
like.py
View File

@ -6,6 +6,7 @@ __maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net" __email__ = "bob@freedombone.net"
__status__ = "Production" __status__ = "Production"
from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import urlPermitted from utils import urlPermitted
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -66,11 +67,7 @@ def like(recentPostsCache: {},
if not urlPermitted(objectUrl, federationList): if not urlPermitted(objectUrl, federationList):
return None return None
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
newLikeJson = { newLikeJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -132,11 +129,7 @@ def likePost(recentPostsCache: {},
debug: bool, projectVersion: str) -> {}: debug: bool, projectVersion: str) -> {}:
"""Likes a given status post. This is only used by unit tests """Likes a given status post. This is only used by unit tests
""" """
likeDomain = likeDomain likeDomain = getFullDomain(likeDomain, likePort)
if likePort:
if likePort != 80 and likePort != 443:
if ':' not in likeDomain:
likeDomain = likeDomain + ':' + str(likePort)
actorLiked = httpPrefix + '://' + likeDomain + '/users/' + likeNickname actorLiked = httpPrefix + '://' + likeDomain + '/users/' + likeNickname
objectUrl = actorLiked + '/statuses/' + str(likeStatusNumber) objectUrl = actorLiked + '/statuses/' + str(likeStatusNumber)
@ -165,11 +158,7 @@ def undolike(recentPostsCache: {},
if not urlPermitted(objectUrl, federationList): if not urlPermitted(objectUrl, federationList):
return None return None
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
newUndoLikeJson = { newUndoLikeJson = {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
@ -234,11 +223,7 @@ def sendLikeViaServer(baseDir: str, session,
print('WARN: No session for sendLikeViaServer') print('WARN: No session for sendLikeViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname
@ -313,11 +298,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
print('WARN: No session for sendUndoLikeViaServer') print('WARN: No session for sendUndoLikeViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname

View File

@ -13,6 +13,7 @@ import os
import datetime import datetime
from hashlib import sha1 from hashlib import sha1
from auth import createPassword from auth import createPassword
from utils import getFullDomain
from utils import getImageExtensions from utils import getImageExtensions
from utils import getVideoExtensions from utils import getVideoExtensions
from utils import getAudioExtensions from utils import getAudioExtensions
@ -163,10 +164,7 @@ def attachMedia(baseDir: str, httpPrefix: str, domain: str, port: int,
if mediaType == 'audio/mpeg': if mediaType == 'audio/mpeg':
fileExtension = 'mp3' fileExtension = 'mp3'
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
mPath = getMediaPath() mPath = getMediaPath()
mediaPath = mPath + '/' + createPassword(32) + '.' + fileExtension mediaPath = mPath + '/' + createPassword(32) + '.' + fileExtension

View File

@ -26,6 +26,7 @@ from posts import archivePostsForPerson
from content import removeHtmlTag from content import removeHtmlTag
from content import dangerousMarkup from content import dangerousMarkup
from content import validHashTag from content import validHashTag
from utils import getFullDomain
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getStatusNumber from utils import getStatusNumber
@ -245,10 +246,7 @@ def newswireHashtagProcessing(session, baseDir: str, postJsonObject: {},
with open(rulesFilename, "r") as f: with open(rulesFilename, "r") as f:
rules = f.readlines() rules = f.readlines()
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
# get the full text content of the post # get the full text content of the post
content = '' content = ''
@ -584,10 +582,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
blog['object']['content'] = rssDescription blog['object']['content'] = rssDescription
blog['object']['contentMap']['en'] = rssDescription blog['object']['contentMap']['en'] = rssDescription
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
hashtags = item[6] hashtags = item[6]

View File

@ -14,6 +14,7 @@ from posts import outboxMessageCreateWrap
from posts import savePostToBox from posts import savePostToBox
from posts import sendToFollowersThread from posts import sendToFollowersThread
from posts import sendToNamedAddresses from posts import sendToNamedAddresses
from utils import getFullDomain
from utils import removeIdEnding from utils import removeIdEnding
from utils import getDomainFromActor from utils import getDomainFromActor
from blocking import isBlockedDomain from blocking import isBlockedDomain
@ -113,9 +114,7 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
str(messageJson)) str(messageJson))
return False return False
testDomain, testPort = getDomainFromActor(messageJson['actor']) testDomain, testPort = getDomainFromActor(messageJson['actor'])
if testPort: testDomain = getFullDomain(testDomain, testPort)
if testPort != 80 and testPort != 443:
testDomain = testDomain + ':' + str(testPort)
if isBlockedDomain(baseDir, testDomain): if isBlockedDomain(baseDir, testDomain):
if debug: if debug:
print('DEBUG: domain is blocked: ' + messageJson['actor']) print('DEBUG: domain is blocked: ' + messageJson['actor'])

View File

@ -35,6 +35,7 @@ from auth import storeBasicCredentials
from auth import removePassword from auth import removePassword
from roles import setRole from roles import setRole
from media import removeMetaData from media import removeMetaData
from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
@ -68,11 +69,7 @@ def setProfileImage(baseDir: str, httpPrefix: str, nickname: str, domain: str,
if ':' in domain: if ':' in domain:
domain = domain.split(':')[0] domain = domain.split(':')[0]
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
personFilename = baseDir + '/accounts/' + handle + '.json' personFilename = baseDir + '/accounts/' + handle + '.json'
@ -193,7 +190,8 @@ def getDefaultPersonContext() -> str:
'identityKey': {'@id': 'toot:identityKey', '@type': '@id'}, 'identityKey': {'@id': 'toot:identityKey', '@type': '@id'},
'fingerprintKey': {'@id': 'toot:fingerprintKey', '@type': '@id'}, 'fingerprintKey': {'@id': 'toot:fingerprintKey', '@type': '@id'},
'messageFranking': 'toot:messageFranking', 'messageFranking': 'toot:messageFranking',
'publicKeyBase64': 'toot:publicKeyBase64' 'publicKeyBase64': 'toot:publicKeyBase64',
'discoverable': 'toot:discoverable'
} }
@ -213,10 +211,7 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
handle = nickname + '@' + domain handle = nickname + '@' + domain
originalDomain = domain originalDomain = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
personType = 'Person' personType = 'Person'
# Enable follower approval by default # Enable follower approval by default
@ -285,6 +280,7 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
}, },
'inbox': inboxStr, 'inbox': inboxStr,
'manuallyApprovesFollowers': approveFollowers, 'manuallyApprovesFollowers': approveFollowers,
'discoverable': False,
'name': personName, 'name': personName,
'outbox': personId+'/outbox', 'outbox': personId+'/outbox',
'preferredUsername': personName, 'preferredUsername': personName,
@ -418,10 +414,7 @@ def savePersonQrcode(baseDir: str,
nickname + '@' + domain + '/qrcode.png' nickname + '@' + domain + '/qrcode.png'
if os.path.isfile(qrcodeFilename): if os.path.isfile(qrcodeFilename):
return return
handle = '@' + nickname + '@' + domain handle = getFullDomain('@' + nickname + '@' + domain, port)
if port:
if port != 80 and port != 443:
handle = handle + ':' + str(port)
url = pyqrcode.create(handle) url = pyqrcode.create(handle)
url.png(qrcodeFilename, scale) url.png(qrcodeFilename, scale)
@ -868,11 +861,7 @@ def canRemovePost(baseDir: str, nickname: str,
if '/statuses/' not in postId: if '/statuses/' not in postId:
return False return False
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
# is the post by the admin? # is the post by the admin?
adminNickname = getConfigParam(baseDir, 'admin') adminNickname = getConfigParam(baseDir, 'admin')
@ -898,11 +887,7 @@ def removeTagsForNickname(baseDir: str, nickname: str,
""" """
if not os.path.isdir(baseDir + '/tags'): if not os.path.isdir(baseDir + '/tags'):
return return
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
matchStr = domainFull + '/users/' + nickname + '/' matchStr = domainFull + '/users/' + nickname + '/'
directory = os.fsencode(baseDir + '/tags/') directory = os.fsencode(baseDir + '/tags/')
for f in os.scandir(directory): for f in os.scandir(directory):

262
posts.py
View File

@ -30,6 +30,7 @@ from session import postJsonString
from session import postImage from session import postImage
from webfinger import webfingerHandle from webfinger import webfingerHandle
from httpsig import createSignedHeader from httpsig import createSignedHeader
from utils import getFullDomain
from utils import getFollowersList from utils import getFollowersList
from utils import isEvil from utils import isEvil
from utils import removeIdEnding from utils import removeIdEnding
@ -59,6 +60,7 @@ from content import replaceEmojiFromTags
from content import removeTextFormatting from content import removeTextFormatting
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from blocking import isBlocked from blocking import isBlocked
from blocking import isBlockedDomain
from filters import isFiltered from filters import isFiltered
from git import convertPostToPatch from git import convertPostToPatch
from jsonldsig import jsonldSign from jsonldsig import jsonldSign
@ -506,6 +508,76 @@ def getPostDomains(session, outboxUrl: str, maxPosts: int,
return postDomains return postDomains
def getPostsForBlockedDomains(baseDir: str,
session, outboxUrl: str, maxPosts: int,
maxMentions: int,
maxEmoji: int, maxAttachments: int,
federationList: [],
personCache: {},
debug: bool,
projectVersion: str, httpPrefix: str,
domain: str) -> {}:
"""Returns a dictionary of posts for blocked domains
"""
if not outboxUrl:
return {}
profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if '/outbox/' in outboxUrl:
asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
blockedPosts = {}
i = 0
userFeed = parseUserFeed(session, outboxUrl, asHeader,
projectVersion, httpPrefix, domain)
for item in userFeed:
i += 1
if i > maxPosts:
break
if not item.get('object'):
continue
if not isinstance(item['object'], dict):
continue
if item['object'].get('inReplyTo'):
if isinstance(item['object']['inReplyTo'], str):
postDomain, postPort = \
getDomainFromActor(item['object']['inReplyTo'])
if isBlockedDomain(baseDir, postDomain):
if item['object'].get('url'):
url = item['object']['url']
else:
url = item['object']['id']
if not blockedPosts.get(postDomain):
blockedPosts[postDomain] = [url]
else:
if url not in blockedPosts[postDomain]:
blockedPosts[postDomain].append(url)
if item['object'].get('tag'):
for tagItem in item['object']['tag']:
tagType = tagItem['type'].lower()
if tagType == 'mention':
if tagItem.get('href'):
postDomain, postPort = \
getDomainFromActor(tagItem['href'])
if isBlockedDomain(baseDir, postDomain):
if item['object'].get('url'):
url = item['object']['url']
else:
url = item['object']['id']
if not blockedPosts.get(postDomain):
blockedPosts[postDomain] = [url]
else:
if url not in blockedPosts[postDomain]:
blockedPosts[postDomain].append(url)
return blockedPosts
def deleteAllPosts(baseDir: str, def deleteAllPosts(baseDir: str,
nickname: str, domain: str, boxname: str) -> None: nickname: str, domain: str, boxname: str) -> None:
"""Deletes all posts for a person from inbox or outbox """Deletes all posts for a person from inbox or outbox
@ -740,10 +812,7 @@ def createPostBase(baseDir: str, nickname: str, domain: str, port: int,
tags = [] tags = []
hashtagsDict = {} hashtagsDict = {}
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
# add tags # add tags
if nickname != 'news': if nickname != 'news':
@ -1070,10 +1139,7 @@ def outboxMessageCreateWrap(httpPrefix: str,
https://www.w3.org/TR/activitypub/#object-without-create https://www.w3.org/TR/activitypub/#object-without-create
""" """
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
if messageJson.get('published'): if messageJson.get('published'):
published = messageJson['published'] published = messageJson['published']
@ -1108,10 +1174,7 @@ def postIsAddressedToFollowers(baseDir: str,
postJsonObject: {}) -> bool: postJsonObject: {}) -> 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
""" """
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
if not postJsonObject.get('object'): if not postJsonObject.get('object'):
return False return False
@ -1174,11 +1237,7 @@ def createPublicPost(baseDir: str,
eventDate=None, eventTime=None, location=None) -> {}: eventDate=None, eventTime=None, location=None) -> {}:
"""Public post """Public post
""" """
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
return createPostBase(baseDir, nickname, domain, port, return createPostBase(baseDir, nickname, domain, port,
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
httpPrefix + '://' + domainFull + '/users/' + httpPrefix + '://' + domainFull + '/users/' +
@ -1278,11 +1337,7 @@ def createQuestionPost(baseDir: str,
subject: str, durationDays: int) -> {}: subject: str, durationDays: int) -> {}:
"""Question post with multiple choice options """Question post with multiple choice options
""" """
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
messageJson = \ messageJson = \
createPostBase(baseDir, nickname, domain, port, createPostBase(baseDir, nickname, domain, port,
'https://www.w3.org/ns/activitystreams#Public', 'https://www.w3.org/ns/activitystreams#Public',
@ -1328,11 +1383,7 @@ def createUnlistedPost(baseDir: str,
eventDate=None, eventTime=None, location=None) -> {}: eventDate=None, eventTime=None, location=None) -> {}:
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
return createPostBase(baseDir, nickname, domain, port, return createPostBase(baseDir, nickname, domain, port,
httpPrefix + '://' + domainFull + '/users/' + httpPrefix + '://' + domainFull + '/users/' +
nickname + '/followers', nickname + '/followers',
@ -1361,11 +1412,7 @@ def createFollowersOnlyPost(baseDir: str,
location=None) -> {}: location=None) -> {}:
"""Followers only post """Followers only post
""" """
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
return createPostBase(baseDir, nickname, domain, port, return createPostBase(baseDir, nickname, domain, port,
httpPrefix + '://' + domainFull + '/users/' + httpPrefix + '://' + domainFull + '/users/' +
nickname + '/followers', nickname + '/followers',
@ -1404,11 +1451,7 @@ def createEventPost(baseDir: str,
if not category: if not category:
print('Event has no category') print('Event has no category')
return None return None
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
# create event uuid # create event uuid
eventUUID = str(uuid.uuid1()) eventUUID = str(uuid.uuid1())
@ -1524,11 +1567,7 @@ def createReportPost(baseDir: str,
debug: bool, subject=None) -> {}: debug: bool, subject=None) -> {}:
"""Send a report to moderators """Send a report to moderators
""" """
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(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'
@ -1698,10 +1737,7 @@ def sendPost(projectVersion: str,
# shared inbox actor on @domain@domain # shared inbox actor on @domain@domain
toNickname = toDomain toNickname = toDomain
if toPort: toDomain = getFullDomain(toDomain, toPort)
if toPort != 80 and toPort != 443:
if ':' not in toDomain:
toDomain = toDomain + ':' + str(toPort)
handle = httpPrefix + '://' + toDomain + '/@' + toNickname handle = httpPrefix + '://' + toDomain + '/@' + toNickname
@ -1816,10 +1852,7 @@ def sendPostViaServer(projectVersion: str,
print('WARN: No session for sendPostViaServer') print('WARN: No session for sendPostViaServer')
return 6 return 6
if toPort: fromDomain = getFullDomain(fromDomain, fromPort)
if toPort != 80 and toPort != 443:
if ':' not in fromDomain:
fromDomain = fromDomain + ':' + str(fromPort)
handle = httpPrefix + '://' + fromDomain + '/@' + fromNickname handle = httpPrefix + '://' + fromDomain + '/@' + fromNickname
@ -1863,11 +1896,7 @@ def sendPostViaServer(projectVersion: str,
clientToServer = True clientToServer = True
if toDomain.lower().endswith('public'): if toDomain.lower().endswith('public'):
toPersonId = 'https://www.w3.org/ns/activitystreams#Public' toPersonId = 'https://www.w3.org/ns/activitystreams#Public'
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
cc = httpPrefix + '://' + fromDomainFull + '/users/' + \ cc = httpPrefix + '://' + fromDomainFull + '/users/' + \
fromNickname + '/followers' fromNickname + '/followers'
else: else:
@ -1877,11 +1906,7 @@ def sendPostViaServer(projectVersion: str,
httpPrefix + '://' + \ httpPrefix + '://' + \
fromDomainFull + '/users/' + fromNickname + '/followers' fromDomainFull + '/users/' + fromNickname + '/followers'
else: else:
toDomainFull = toDomain toDomainFull = getFullDomain(toDomain, toPort)
if toPort:
if toPort != 80 and toPort != 443:
if ':' not in toDomain:
toDomainFull = toDomain + ':' + str(toPort)
toPersonId = httpPrefix + '://' + toDomainFull + \ toPersonId = httpPrefix + '://' + toDomainFull + \
'/users/' + toNickname '/users/' + toNickname
@ -2010,10 +2035,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
toNickname = toDomain toNickname = toDomain
# sharedInbox = True # sharedInbox = True
if toPort: toDomain = getFullDomain(toDomain, toPort)
if toPort != 80 and toPort != 443:
if ':' not in toDomain:
toDomain = toDomain + ':' + str(toPort)
toDomainUrl = httpPrefix + '://' + toDomain toDomainUrl = httpPrefix + '://' + toDomain
if not siteIsActive(toDomainUrl): if not siteIsActive(toDomainUrl):
@ -2290,16 +2312,8 @@ def sendToNamedAddresses(session, baseDir: str,
if not toDomain: if not toDomain:
continue continue
if debug: if debug:
domainFull = domain domainFull = getFullDomain(domain, port)
if port: toDomainFull = getFullDomain(toDomain, toPort)
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
toDomainFull = toDomain
if toPort:
if toPort != 80 and toPort != 443:
if ':' not in toDomain:
toDomainFull = toDomain + ':' + str(toPort)
print('DEBUG: Post sending s2s: ' + nickname + '@' + domainFull + print('DEBUG: Post sending s2s: ' + nickname + '@' + domainFull +
' to ' + toNickname + '@' + toDomainFull) ' to ' + toNickname + '@' + toDomainFull)
@ -2618,10 +2632,7 @@ def createModeration(baseDir: str, nickname: str, domain: str, port: int,
boxDir = createPersonDir(nickname, domain, baseDir, 'inbox') boxDir = createPersonDir(nickname, domain, baseDir, 'inbox')
boxname = 'moderation' boxname = 'moderation'
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
if not pageNumber: if not pageNumber:
pageNumber = 1 pageNumber = 1
@ -2939,10 +2950,7 @@ def createBoxIndexed(recentPostsCache: {},
indexBoxName = boxname indexBoxName = boxname
timelineNickname = 'news' timelineNickname = 'news'
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
boxActor = httpPrefix + '://' + domain + '/users/' + nickname boxActor = httpPrefix + '://' + domain + '/users/' + nickname
@ -3332,11 +3340,7 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
cachedWebfingers = {} cachedWebfingers = {}
federationList = [] federationList = []
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
handle = httpPrefix + "://" + domainFull + "/@" + nickname handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers, webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
@ -3377,11 +3381,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
cachedWebfingers = {} cachedWebfingers = {}
federationList = [] federationList = []
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
handle = httpPrefix + "://" + domainFull + "/@" + nickname handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers, webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
@ -3411,6 +3411,67 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
return postDomains return postDomains
def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
proxyType: str, port: int, httpPrefix: str,
debug: bool, projectVersion: str) -> []:
""" Returns a dict of domains referenced within public posts
"""
if not session:
session = createSession(proxyType)
if not session:
return {}
personCache = {}
cachedWebfingers = {}
federationList = []
domainFull = getFullDomain(domain, port)
handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion)
if not wfRequest:
return {}
if not isinstance(wfRequest, dict):
print('Webfinger for ' + handle + ' did not return a dict. ' +
str(wfRequest))
return {}
(personUrl, pubKeyId, pubKey,
personId, sharedInbox,
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
personCache,
projectVersion, httpPrefix,
nickname, domain, 'outbox')
maxMentions = 99
maxEmoji = 99
maxAttachments = 5
maxPosts = 64
postDomains = \
getPostDomains(session, personUrl, maxPosts, maxMentions, maxEmoji,
maxAttachments, federationList,
personCache, debug,
projectVersion, httpPrefix, domain, [])
postDomains.sort()
domainsInfo = {}
for d in postDomains:
if not domainsInfo.get(d):
domainsInfo[d] = []
blockedPosts = \
getPostsForBlockedDomains(baseDir, session, personUrl, maxPosts,
maxMentions,
maxEmoji, maxAttachments,
federationList,
personCache,
debug,
projectVersion, httpPrefix,
domain)
for blockedDomain, postUrlList in blockedPosts.items():
domainsInfo[blockedDomain] += postUrlList
return domainsInfo
def getPublicPostDomainsBlocked(session, baseDir: str, def getPublicPostDomainsBlocked(session, baseDir: str,
nickname: str, domain: str, nickname: str, domain: str,
proxyType: str, port: int, httpPrefix: str, proxyType: str, port: int, httpPrefix: str,
@ -3740,10 +3801,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
attributedDomain, attributedPort = \ attributedDomain, attributedPort = \
getDomainFromActor(announcedJson['object']['id']) getDomainFromActor(announcedJson['object']['id'])
if attributedNickname and attributedDomain: if attributedNickname and attributedDomain:
if attributedPort: attributedDomain = getFullDomain(attributedDomain, attributedPort)
if attributedPort != 80 and attributedPort != 443:
attributedDomain = \
attributedDomain + ':' + str(attributedPort)
if isBlocked(baseDir, nickname, domain, if isBlocked(baseDir, nickname, domain,
attributedNickname, attributedDomain): attributedNickname, attributedDomain):
rejectAnnounce(announceFilename) rejectAnnounce(announceFilename)
@ -3859,11 +3917,7 @@ def sendBlockViaServer(baseDir: str, session,
print('WARN: No session for sendBlockViaServer') print('WARN: No session for sendBlockViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + \ ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + \
@ -3942,11 +3996,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
print('WARN: No session for sendBlockViaServer') print('WARN: No session for sendBlockViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + \ ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + \

View File

@ -11,6 +11,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -259,12 +260,7 @@ def sendRoleViaServer(baseDir: str, session,
print('WARN: No session for sendRoleViaServer') print('WARN: No session for sendRoleViaServer')
return 6 return 6
delegatorDomainFull = delegatorDomain delegatorDomainFull = getFullDomain(delegatorDomain, delegatorPort)
if delegatorPort:
if delegatorPort != 80 and delegatorPort != 443:
if ':' not in delegatorDomain:
delegatorDomainFull = \
delegatorDomain + ':' + str(delegatorPort)
toUrl = \ toUrl = \
httpPrefix + '://' + delegatorDomainFull + '/users/' + nickname httpPrefix + '://' + delegatorDomainFull + '/users/' + nickname

View File

@ -13,6 +13,7 @@ from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from session import postImage from session import postImage
from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
@ -115,11 +116,7 @@ def addShare(baseDir: str,
imageFilename = sharesImageFilename + '.' + ext imageFilename = sharesImageFilename + '.' + ext
moveImage = True moveImage = True
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(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:
@ -247,10 +244,7 @@ def getSharesFeedForPerson(baseDir: str,
if not validNickname(domain, nickname): if not validNickname(domain, nickname):
return None return None
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
handleDomain = domain handleDomain = domain
if ':' in handleDomain: if ':' in handleDomain:
@ -331,11 +325,7 @@ def sendShareViaServer(baseDir, session,
print('WARN: No session for sendShareViaServer') print('WARN: No session for sendShareViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + \ ccUrl = httpPrefix + '://' + fromDomainFull + \
@ -439,11 +429,7 @@ def sendUndoShareViaServer(baseDir: str, session,
print('WARN: No session for sendUndoShareViaServer') print('WARN: No session for sendUndoShareViaServer')
return 6 return 6
fromDomainFull = fromDomain fromDomainFull = getFullDomain(fromDomain, fromPort)
if fromPort:
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
fromDomainFull = fromDomain + ':' + str(fromPort)
toUrl = 'https://www.w3.org/ns/activitystreams#Public' toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + \ ccUrl = httpPrefix + '://' + fromDomainFull + \

View File

@ -11,6 +11,7 @@ from webfinger import webfingerHandle
from auth import createBasicAuthHeader from auth import createBasicAuthHeader
from posts import getPersonBox from posts import getPersonBox
from session import postJson from session import postJson
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import loadJson from utils import loadJson
@ -108,11 +109,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
print('WARN: No session for sendSkillViaServer') print('WARN: No session for sendSkillViaServer')
return 6 return 6
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
toUrl = actor toUrl = actor

View File

@ -10,6 +10,7 @@ from session import createSession
from webfinger import webfingerHandle from webfinger import webfingerHandle
from posts import getPersonBox from posts import getPersonBox
from posts import getPostDomains from posts import getPostDomains
from utils import getFullDomain
def instancesGraph(baseDir: str, handles: str, def instancesGraph(baseDir: str, handles: str,
@ -46,11 +47,7 @@ def instancesGraph(baseDir: str, handles: str,
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
domain = handle.split('@')[1] domain = handle.split('@')[1]
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
handle = httpPrefix + "://" + domainFull + "/@" + nickname handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \ wfRequest = \
webfingerHandle(session, handle, httpPrefix, webfingerHandle(session, handle, httpPrefix,

View File

@ -33,6 +33,7 @@ from follow import clearFollows
from follow import clearFollowers from follow import clearFollowers
from follow import sendFollowRequestViaServer from follow import sendFollowRequestViaServer
from follow import sendUnfollowRequestViaServer from follow import sendUnfollowRequestViaServer
from utils import getFullDomain
from utils import validNickname from utils import validNickname
from utils import firstParagraphFromString from utils import firstParagraphFromString
from utils import removeIdEnding from utils import removeIdEnding
@ -127,11 +128,7 @@ def testHttpsigBase(withDigest):
} }
messageBodyJsonStr = json.dumps(messageBodyJson) messageBodyJsonStr = json.dumps(messageBodyJson)
headersDomain = domain headersDomain = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
headersDomain = domain + ':' + str(port)
dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime()) dateStr = strftime("%a, %d %b %Y %H:%M:%S %Z", gmtime())
boxpath = '/inbox' boxpath = '/inbox'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -0,0 +1,2 @@
Banner theme is Emma Goldman speaking in Paterson NJ to members of the IWW. 16th Dec 1913.
Font, post separator and globe image is from Mother Earth magazine.

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed",
"Ask about a shared item.": "اسأل عن عنصر مشترك.", "Ask about a shared item.": "اسأل عن عنصر مشترك.",
"Account Information": "معلومات الحساب", "Account Information": "معلومات الحساب",
"This account interacts with the following instances": "يتفاعل هذا الحساب مع الحالات التالية" "This account interacts with the following instances": "يتفاعل هذا الحساب مع الحالات التالية",
"News posts are moderated": "المشاركات الإخبارية خاضعة للإشراف"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Feed RSS de categories de hashtag", "Hashtag Categories RSS Feed": "Feed RSS de categories de hashtag",
"Ask about a shared item.": "Pregunteu sobre un element compartit.", "Ask about a shared item.": "Pregunteu sobre un element compartit.",
"Account Information": "Informació del compte", "Account Information": "Informació del compte",
"This account interacts with the following instances": "Aquest compte interactua amb les instàncies següents" "This account interacts with the following instances": "Aquest compte interactua amb les instàncies següents",
"News posts are moderated": "Les publicacions de notícies es moderen"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Categorïau Hashtag RSS Feed", "Hashtag Categories RSS Feed": "Categorïau Hashtag RSS Feed",
"Ask about a shared item.": "Gofynnwch am eitem a rennir.", "Ask about a shared item.": "Gofynnwch am eitem a rennir.",
"Account Information": "Gwybodaeth Gyfrif", "Account Information": "Gwybodaeth Gyfrif",
"This account interacts with the following instances": "Mae'r cyfrif hwn yn rhyngweithio â'r achosion canlynol" "This account interacts with the following instances": "Mae'r cyfrif hwn yn rhyngweithio â'r achosion canlynol",
"News posts are moderated": "Mae swyddi newyddion yn cael eu cymedroli"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Hashtag Kategorien RSS Feed", "Hashtag Categories RSS Feed": "Hashtag Kategorien RSS Feed",
"Ask about a shared item.": "Fragen Sie nach einem gemeinsamen Artikel.", "Ask about a shared item.": "Fragen Sie nach einem gemeinsamen Artikel.",
"Account Information": "Kontoinformationen", "Account Information": "Kontoinformationen",
"This account interacts with the following instances": "Dieses Konto interagiert mit den folgenden Instanzen" "This account interacts with the following instances": "Dieses Konto interagiert mit den folgenden Instanzen",
"News posts are moderated": "Nachrichtenbeiträge werden moderiert"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed",
"Ask about a shared item.": "Ask about a shared item.", "Ask about a shared item.": "Ask about a shared item.",
"Account Information": "Account Information", "Account Information": "Account Information",
"This account interacts with the following instances": "This account interacts with the following instances" "This account interacts with the following instances": "This account interacts with the following instances",
"News posts are moderated": "News posts are moderated"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Feed RSS de categorías de hashtags", "Hashtag Categories RSS Feed": "Feed RSS de categorías de hashtags",
"Ask about a shared item.": "Pregunte por un elemento compartido.", "Ask about a shared item.": "Pregunte por un elemento compartido.",
"Account Information": "Información de la cuenta", "Account Information": "Información de la cuenta",
"This account interacts with the following instances": "Esta cuenta interactúa con las siguientes instancias" "This account interacts with the following instances": "Esta cuenta interactúa con las siguientes instancias",
"News posts are moderated": "Las publicaciones de noticias están moderadas"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Flux RSS des catégories Hashtag", "Hashtag Categories RSS Feed": "Flux RSS des catégories Hashtag",
"Ask about a shared item.": "Renseignez-vous sur un élément partagé.", "Ask about a shared item.": "Renseignez-vous sur un élément partagé.",
"Account Information": "Information sur le compte", "Account Information": "Information sur le compte",
"This account interacts with the following instances": "Ce compte interagit avec les instances suivantes" "This account interacts with the following instances": "Ce compte interagit avec les instances suivantes",
"News posts are moderated": "Les articles d'actualité sont modérés"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Catagóirí Hashtag RSS Feed", "Hashtag Categories RSS Feed": "Catagóirí Hashtag RSS Feed",
"Ask about a shared item.": "Fiafraigh faoi earra roinnte.", "Ask about a shared item.": "Fiafraigh faoi earra roinnte.",
"Account Information": "Faisnéis Chuntais", "Account Information": "Faisnéis Chuntais",
"This account interacts with the following instances": "Idirghníomhaíonn an cuntas seo leis na cásanna seo a leanas" "This account interacts with the following instances": "Idirghníomhaíonn an cuntas seo leis na cásanna seo a leanas",
"News posts are moderated": "Déantar poist nuachta a mhodhnú"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "हैशटैग श्रेणियाँ आरएसएस फ़ीड", "Hashtag Categories RSS Feed": "हैशटैग श्रेणियाँ आरएसएस फ़ीड",
"Ask about a shared item.": "एक साझा आइटम के बारे में पूछें।", "Ask about a shared item.": "एक साझा आइटम के बारे में पूछें।",
"Account Information": "खाते की जानकारी", "Account Information": "खाते की जानकारी",
"This account interacts with the following instances": "यह खाता निम्नलिखित उदाहरणों के साथ सहभागिता करता है" "This account interacts with the following instances": "यह खाता निम्नलिखित उदाहरणों के साथ सहभागिता करता है",
"News posts are moderated": "समाचार पोस्ट संचालित होते हैं"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Feed RSS delle categorie hashtag", "Hashtag Categories RSS Feed": "Feed RSS delle categorie hashtag",
"Ask about a shared item.": "Chiedi informazioni su un elemento condiviso.", "Ask about a shared item.": "Chiedi informazioni su un elemento condiviso.",
"Account Information": "Informazioni account", "Account Information": "Informazioni account",
"This account interacts with the following instances": "Questo account interagisce con le seguenti istanze" "This account interacts with the following instances": "Questo account interagisce con le seguenti istanze",
"News posts are moderated": "I post di notizie sono moderati"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "ハッシュタグカテゴリRSSフィード", "Hashtag Categories RSS Feed": "ハッシュタグカテゴリRSSフィード",
"Ask about a shared item.": "共有アイテムについて質問します。", "Ask about a shared item.": "共有アイテムについて質問します。",
"Account Information": "口座情報", "Account Information": "口座情報",
"This account interacts with the following instances": "このアカウントは、次のインスタンスと相互作用します" "This account interacts with the following instances": "このアカウントは、次のインスタンスと相互作用します",
"News posts are moderated": "ニュース投稿はモデレートされます"
} }

View File

@ -337,5 +337,6 @@
"Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed", "Hashtag Categories RSS Feed": "Hashtag Categories RSS Feed",
"Ask about a shared item.": "Ask about a shared item.", "Ask about a shared item.": "Ask about a shared item.",
"Account Information": "Account Information", "Account Information": "Account Information",
"This account interacts with the following instances": "This account interacts with the following instances" "This account interacts with the following instances": "This account interacts with the following instances",
"News posts are moderated": "News posts are moderated"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "Feed RSS das categorias de hashtag", "Hashtag Categories RSS Feed": "Feed RSS das categorias de hashtag",
"Ask about a shared item.": "Pergunte sobre um item compartilhado.", "Ask about a shared item.": "Pergunte sobre um item compartilhado.",
"Account Information": "Informação da conta", "Account Information": "Informação da conta",
"This account interacts with the following instances": "Esta conta interage com as seguintes instâncias" "This account interacts with the following instances": "Esta conta interage com as seguintes instâncias",
"News posts are moderated": "Postagens de notícias são moderadas"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "RSS-канал категорий хэштегов", "Hashtag Categories RSS Feed": "RSS-канал категорий хэштегов",
"Ask about a shared item.": "Спросите об общем элементе.", "Ask about a shared item.": "Спросите об общем элементе.",
"Account Information": "Информация об аккаунте", "Account Information": "Информация об аккаунте",
"This account interacts with the following instances": "Этот аккаунт взаимодействует со следующими экземплярами" "This account interacts with the following instances": "Этот аккаунт взаимодействует со следующими экземплярами",
"News posts are moderated": "Сообщения новостей модерируются"
} }

View File

@ -341,5 +341,6 @@
"Hashtag Categories RSS Feed": "标签类别RSS提要", "Hashtag Categories RSS Feed": "标签类别RSS提要",
"Ask about a shared item.": "询问共享项目。", "Ask about a shared item.": "询问共享项目。",
"Account Information": "帐户信息", "Account Information": "帐户信息",
"This account interacts with the following instances": "此帐户与以下实例进行交互" "This account interacts with the following instances": "此帐户与以下实例进行交互",
"News posts are moderated": "新闻发布被审核"
} }

View File

@ -19,6 +19,18 @@ from calendar import monthrange
from followingCalendar import addPersonToCalendar from followingCalendar import addPersonToCalendar
def getFullDomain(domain: str, port: int) -> str:
"""Returns the full domain name, including port number
"""
if not port:
return domain
if ':' in domain:
return domain
if port == 80 or port == 443:
return domain
return domain + ':' + str(port)
def isDormant(baseDir: str, nickname: str, domain: str, actor: str, def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
dormantMonths=3) -> bool: dormantMonths=3) -> bool:
"""Is the given followed actor dormant, from the standpoint """Is the given followed actor dormant, from the standpoint

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from shutil import copyfile from shutil import copyfile
from utils import getFullDomain
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from utils import locatePost from utils import locatePost
@ -35,10 +36,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 = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
postFilename = locatePost(baseDir, nickname, domain, messageId) postFilename = locatePost(baseDir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -103,10 +101,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
itemID = getValidSharedItemID(shareName) itemID = getValidSharedItemID(shareName)
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
sharesFile = baseDir + '/accounts/' + \ sharesFile = baseDir + '/accounts/' + \
nickname + '@' + domain + '/shares.json' nickname + '@' + domain + '/shares.json'
if not os.path.isfile(sharesFile): if not os.path.isfile(sharesFile):

View File

@ -9,8 +9,9 @@ __status__ = "Production"
import os import os
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
from posts import getPublicPostDomains from posts import getPublicPostInfo
from webapp_timeline import htmlTimeline from webapp_timeline import htmlTimeline
from webapp_utils import getContentWarningButton
from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter from webapp_utils import htmlFooter
from blocking import isBlockedDomain from blocking import isBlockedDomain
@ -78,29 +79,51 @@ def htmlAccountInfo(cssCache: {}, translate: {},
infoForm += translate[msgStr1] + '</center><br><br>' infoForm += translate[msgStr1] + '</center><br><br>'
proxyType = 'tor' proxyType = 'tor'
domainList = [] if not os.path.isfile('/usr/bin/tor'):
domainList = getPublicPostDomains(None, proxyType = None
baseDir, searchNickname, searchDomain, if domain.endswith('.i2p'):
proxyType, searchPort, proxyType = None
httpPrefix, debug, domainDict = getPublicPostInfo(None,
__version__, domainList) baseDir, searchNickname, searchDomain,
proxyType, searchPort,
httpPrefix, debug,
__version__)
infoForm += '<div class="accountInfoDomains">' infoForm += '<div class="accountInfoDomains">'
usersPath = '/users/' + nickname + '/accountinfo' usersPath = '/users/' + nickname + '/accountinfo'
for postDomain in domainList: ctr = 1
for postDomain, blockedPostUrls in domainDict.items():
infoForm += '<a href="' + \ infoForm += '<a href="' + \
httpPrefix + '://' + postDomain + '">' + postDomain + '</a> ' httpPrefix + '://' + postDomain + '">' + postDomain + '</a> '
if isBlockedDomain(baseDir, postDomain): if isBlockedDomain(baseDir, postDomain):
blockedPostsLinks = ''
urlCtr = 0
for url in blockedPostUrls:
if urlCtr > 0:
blockedPostsLinks += '<br>'
blockedPostsLinks += \
'<a href="' + url + '">' + url + '</a>'
urlCtr += 1
blockedPostsHtml = ''
if blockedPostsLinks:
blockedPostsHtml = \
getContentWarningButton('blockNumber' + str(ctr),
translate, blockedPostsLinks)
ctr += 1
infoForm += \ infoForm += \
'<a href="' + usersPath + '?unblockdomain=' + postDomain + \ '<a href="' + usersPath + '?unblockdomain=' + postDomain + \
'?handle=' + searchHandle + '">' '?handle=' + searchHandle + '">'
infoForm += '<button class="buttonhighlighted"><span>' + \ infoForm += '<button class="buttonhighlighted"><span>' + \
translate['Unblock'] + '</span></button></a>' translate['Unblock'] + '</span></button></a> ' + \
blockedPostsHtml
else: else:
infoForm += \ infoForm += \
'<a href="' + usersPath + '?blockdomain=' + postDomain + \ '<a href="' + usersPath + '?blockdomain=' + postDomain + \
'?handle=' + searchHandle + '">' '?handle=' + searchHandle + '">'
infoForm += '<button class="button"><span>' + \ if postDomain != domain:
translate['Block'] + '</span></button></a>' infoForm += '<button class="button"><span>' + \
translate['Block'] + '</span></button>'
infoForm += '</a>'
infoForm += '<br>' infoForm += '<br>'
infoForm += '</div>' infoForm += '</div>'

View File

@ -11,6 +11,8 @@ from shutil import copyfile
from petnames import getPetName from petnames import getPetName
from person import isPersonSnoozed from person import isPersonSnoozed
from posts import isModerator from posts import isModerator
from utils import getFullDomain
from utils import getConfigParam
from utils import isDormant from utils import isDormant
from utils import removeHtml from utils import removeHtml
from utils import getDomainFromActor from utils import getDomainFromActor
@ -45,10 +47,7 @@ def htmlPersonOptions(defaultTimeline: str,
"""Show options for a person: view/follow/block/report """Show options for a person: view/follow/block/report
""" """
optionsDomain, optionsPort = getDomainFromActor(optionsActor) optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = optionsDomain optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'): if os.path.isfile(baseDir + '/accounts/options-background-custom.jpg'):
if not os.path.isfile(baseDir + '/accounts/options-background.jpg'): if not os.path.isfile(baseDir + '/accounts/options-background.jpg'):
@ -74,10 +73,7 @@ def htmlPersonOptions(defaultTimeline: str,
dormantMonths) dormantMonths)
optionsNickname = getNicknameFromActor(optionsActor) optionsNickname = getNicknameFromActor(optionsActor)
optionsDomainFull = optionsDomain optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
optionsDomainFull = optionsDomain + ':' + str(optionsPort)
if isBlocked(baseDir, nickname, domain, if isBlocked(baseDir, nickname, domain,
optionsNickname, optionsDomainFull): optionsNickname, optionsDomainFull):
blockStr = 'Block' blockStr = 'Block'
@ -187,9 +183,12 @@ def htmlPersonOptions(defaultTimeline: str,
optionsStr += checkboxStr optionsStr += checkboxStr
# checkbox for permission to post to newswire # checkbox for permission to post to newswire
newswirePostsPermitted = False
if optionsDomainFull == domainFull: if optionsDomainFull == domainFull:
if isModerator(baseDir, nickname) and \ adminNickname = getConfigParam(baseDir, 'admin')
not isModerator(baseDir, optionsNickname): if (nickname == adminNickname or
(isModerator(baseDir, nickname) and
not isModerator(baseDir, optionsNickname))):
newswireBlockedFilename = \ newswireBlockedFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.nonewswire' optionsNickname + '@' + optionsDomain + '/.nonewswire'
@ -202,8 +201,26 @@ def htmlPersonOptions(defaultTimeline: str,
translate['Submit'] + '</button><br>\n' translate['Submit'] + '</button><br>\n'
if os.path.isfile(newswireBlockedFilename): if os.path.isfile(newswireBlockedFilename):
checkboxStr = checkboxStr.replace(' checked>', '>') checkboxStr = checkboxStr.replace(' checked>', '>')
else:
newswirePostsPermitted = True
optionsStr += checkboxStr optionsStr += checkboxStr
# whether blogs created by this account are moderated on the newswire
if newswirePostsPermitted:
moderatedFilename = \
baseDir + '/accounts/' + \
optionsNickname + '@' + optionsDomain + '/.newswiremoderated'
checkboxStr = \
' <input type="checkbox" ' + \
'class="profilecheckbox" name="modNewsPosts" checked> ' + \
translate['News posts are moderated'] + \
'\n <button type="submit" class="buttonsmall" ' + \
'name="submitModNewsPosts">' + \
translate['Submit'] + '</button><br>\n'
if not os.path.isfile(moderatedFilename):
checkboxStr = checkboxStr.replace(' checked>', '>')
optionsStr += checkboxStr
optionsStr += optionsLinkStr optionsStr += optionsLinkStr
backPath = '/' backPath = '/'
if nickname: if nickname:
@ -211,26 +228,32 @@ def htmlPersonOptions(defaultTimeline: str,
optionsStr += \ optionsStr += \
' <a href="' + backPath + '"><button type="button" ' + \ ' <a href="' + backPath + '"><button type="button" ' + \
'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \ 'class="buttonIcon" name="submitBack">' + translate['Go Back'] + \
'</button></a>' '</button></a>\n'
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submitView">' + \ ' <button type="submit" class="button" name="submitView">' + \
translate['View'] + '</button>' translate['View'] + '</button>\n'
optionsStr += donateStr optionsStr += donateStr
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submit' + \ ' <button type="submit" class="button" name="submit' + \
followStr + '">' + translate[followStr] + '</button>' followStr + '">' + translate[followStr] + '</button>\n'
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submit' + \ ' <button type="submit" class="button" name="submit' + \
blockStr + '">' + translate[blockStr] + '</button>' blockStr + '">' + translate[blockStr] + '</button>\n'
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submitDM">' + \ ' <button type="submit" class="button" name="submitDM">' + \
translate['DM'] + '</button>' translate['DM'] + '</button>\n'
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submit' + \ ' <button type="submit" class="button" name="submit' + \
snoozeButtonStr + '">' + translate[snoozeButtonStr] + '</button>' snoozeButtonStr + '">' + translate[snoozeButtonStr] + '</button>\n'
optionsStr += \ optionsStr += \
' <button type="submit" class="button" name="submitReport">' + \ ' <button type="submit" class="button" name="submitReport">' + \
translate['Report'] + '</button>' translate['Report'] + '</button>\n'
if isModerator(baseDir, nickname):
optionsStr += \
' <button type="submit" class="button" ' + \
'name="submitPersonInfo">' + \
translate['Info'] + '</button>\n'
personNotes = '' personNotes = ''
personNotesFilename = \ personNotesFilename = \

View File

@ -22,6 +22,7 @@ from posts import getPersonBox
from posts import isDM from posts import isDM
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import populateRepliesJson from posts import populateRepliesJson
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import locatePost from utils import locatePost
from utils import loadJson from utils import loadJson
@ -1135,11 +1136,7 @@ def individualPostAsHtml(allowDownloads: bool,
if messageId: if messageId:
messageIdStr = ';' + messageId messageIdStr = ';' + messageId
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
pageNumberParam = '' pageNumberParam = ''
if pageNumber: if pageNumber:
@ -1604,19 +1601,14 @@ def htmlIndividualPost(cssCache: {},
if likedBy: if likedBy:
likedByNickname = getNicknameFromActor(likedBy) likedByNickname = getNicknameFromActor(likedBy)
likedByDomain, likedByPort = getDomainFromActor(likedBy) likedByDomain, likedByPort = getDomainFromActor(likedBy)
if likedByPort: likedByDomain = getFullDomain(likedByDomain, likedByPort)
if likedByPort != 80 and likedByPort != 443:
likedByDomain += ':' + str(likedByPort)
likedByHandle = likedByNickname + '@' + likedByDomain likedByHandle = likedByNickname + '@' + likedByDomain
postStr += \ postStr += \
'<p>' + translate['Liked by'] + \ '<p>' + translate['Liked by'] + \
' <a href="' + likedBy + '">@' + \ ' <a href="' + likedBy + '">@' + \
likedByHandle + '</a>\n' likedByHandle + '</a>\n'
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
actor = '/users/' + nickname actor = '/users/' + nickname
followStr = ' <form method="POST" ' + \ followStr = ' <form method="POST" ' + \
'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n' 'accept-charset="UTF-8" action="' + actor + '/searchhandle">\n'

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
from pprint import pprint from pprint import pprint
from utils import getFullDomain
from utils import isDormant from utils import isDormant
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -97,11 +98,7 @@ def htmlProfileAfterSearch(cssCache: {},
print('DEBUG: No domain found in ' + profileHandle) print('DEBUG: No domain found in ' + profileHandle)
return None return None
searchDomainFull = searchDomain searchDomainFull = getFullDomain(searchDomain, searchPort)
if searchPort:
if searchPort != 80 and searchPort != 443:
if ':' not in searchDomain:
searchDomainFull = searchDomain + ':' + str(searchPort)
profileStr = '' profileStr = ''
cssFilename = baseDir + '/epicyon-profile.css' cssFilename = baseDir + '/epicyon-profile.css'
@ -225,10 +222,7 @@ def htmlProfileAfterSearch(cssCache: {},
profileDescriptionShort, profileDescriptionShort,
avatarUrl, imageUrl) avatarUrl, imageUrl)
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
followIsPermitted = True followIsPermitted = True
if searchNickname == 'news' and searchDomainFull == domainFull: if searchNickname == 'news' and searchDomainFull == domainFull:
@ -834,11 +828,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
nickname = getNicknameFromActor(path) nickname = getNicknameFromActor(path)
if not nickname: if not nickname:
return '' return ''
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actorFilename = \ actorFilename = \
baseDir + '/accounts/' + nickname + '@' + domain + '.json' baseDir + '/accounts/' + nickname + '@' + domain + '.json'

View File

@ -10,6 +10,7 @@ import os
from shutil import copyfile from shutil import copyfile
import urllib.parse import urllib.parse
from datetime import datetime from datetime import datetime
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import loadJson from utils import loadJson
from utils import getDomainFromActor from utils import getDomainFromActor
@ -544,10 +545,7 @@ def htmlHistorySearch(cssCache: {}, translate: {}, baseDir: str,
htmlHeaderWithExternalStyle(cssFilename) htmlHeaderWithExternalStyle(cssFilename)
# add the page title # add the page title
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
historySearchForm += \ historySearchForm += \
'<center><h1><a href="' + actor + '/search">' + \ '<center><h1><a href="' + actor + '/search">' + \
@ -823,10 +821,7 @@ def rssHashtagSearch(nickname: str, domain: str, port: int,
if not lines: if not lines:
return None return None
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
maxFeedLength = 10 maxFeedLength = 10
hashtagFeed = \ hashtagFeed = \

View File

@ -8,6 +8,7 @@ __status__ = "Production"
import os import os
import time import time
from utils import getFullDomain
from utils import isEditor from utils import isEditor
from utils import removeIdEnding from utils import removeIdEnding
from follow import followerApprovalActive from follow import followerApprovalActive
@ -191,10 +192,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
eventsButton = 'buttonselected' eventsButton = 'buttonselected'
# get the full domain, including any port number # get the full domain, including any port number
fullDomain = domain fullDomain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
fullDomain = domain + ':' + str(port)
usersPath = '/users/' + nickname usersPath = '/users/' + nickname
actor = httpPrefix + '://' + fullDomain + usersPath actor = httpPrefix + '://' + fullDomain + usersPath
@ -399,10 +397,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
tlStr += ' <tbody>\n' tlStr += ' <tbody>\n'
tlStr += ' <tr>\n' tlStr += ' <tr>\n'
domainFull = domain domainFull = getFullDomain(domain, port)
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
# left column # left column
leftColumnStr = \ leftColumnStr = \
@ -449,6 +444,10 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
else: else:
tlStr += ' <input type="text" ' + \ tlStr += ' <input type="text" ' + \
'name="moderationAction" value="" autofocus><br>\n' 'name="moderationAction" value="" autofocus><br>\n'
tlStr += \
' <input type="submit" title="' + \
translate['Information about current blocks/suspensions'] + \
'" name="submitInfo" value="' + translate['Info'] + '">\n'
tlStr += \ tlStr += \
' <input type="submit" title="' + \ ' <input type="submit" title="' + \
translate['Remove the above item'] + \ translate['Remove the above item'] + \
@ -471,10 +470,6 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
' <input type="submit" title="' + \ ' <input type="submit" title="' + \
translate['Unblock an account on another instance'] + \ translate['Unblock an account on another instance'] + \
'" name="submitUnblock" value="' + translate['Unblock'] + '">\n' '" name="submitUnblock" value="' + translate['Unblock'] + '">\n'
tlStr += \
' <input type="submit" title="' + \
translate['Information about current blocks/suspensions'] + \
'" name="submitInfo" value="' + translate['Info'] + '">\n'
tlStr += '</div>\n</form>\n' tlStr += '</div>\n</form>\n'
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '6') logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '6')
@ -655,10 +650,7 @@ def htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
sharesJson, lastPage = \ sharesJson, lastPage = \
sharesTimelineJson(actor, pageNumber, itemsPerPage, sharesTimelineJson(actor, pageNumber, itemsPerPage,
baseDir, maxSharesPerAccount) baseDir, maxSharesPerAccount)
domainFull = domain domainFull = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domainFull = domain + ':' + str(port)
actor = httpPrefix + '://' + domainFull + '/users/' + nickname actor = httpPrefix + '://' + domainFull + '/users/' + nickname
timelineStr = '' timelineStr = ''

View File

@ -18,6 +18,7 @@ import urllib.parse
from session import getJson from session import getJson
from cache import storeWebfingerInCache from cache import storeWebfingerInCache
from cache import getWebfingerFromCache from cache import getWebfingerFromCache
from utils import getFullDomain
from utils import loadJson from utils import loadJson
from utils import loadJsonOnionify from utils import loadJsonOnionify
from utils import saveJson from utils import saveJson
@ -113,10 +114,7 @@ def storeWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Stores webfinger endpoint for a user to a file """Stores webfinger endpoint for a user to a file
""" """
originalDomain = domain originalDomain = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
handle = nickname + '@' + domain handle = nickname + '@' + domain
wfSubdir = '/wfendpoints' wfSubdir = '/wfendpoints'
if not os.path.isdir(baseDir + wfSubdir): if not os.path.isdir(baseDir + wfSubdir):
@ -135,10 +133,7 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int,
"""Creates a webfinger endpoint for a user """Creates a webfinger endpoint for a user
""" """
originalDomain = domain originalDomain = domain
if port: domain = getFullDomain(domain, port)
if port != 80 and port != 443:
if ':' not in domain:
domain = domain + ':' + str(port)
personName = nickname personName = nickname
personId = httpPrefix + "://" + domain + "/users/" + personName personId = httpPrefix + "://" + domain + "/users/" + personName
@ -245,10 +240,7 @@ def webfingerLookup(path: str, baseDir: str,
if debug: if debug:
print('DEBUG: WEBFINGER no @ in handle ' + handle) print('DEBUG: WEBFINGER no @ in handle ' + handle)
return None return None
if port: handle = getFullDomain(handle, port)
if port != 80 and port != 443:
if ':' not in handle:
handle = handle + ':' + str(port)
# convert @domain@domain to inbox@domain # convert @domain@domain to inbox@domain
if '@' in handle: if '@' in handle:
handleDomain = handle.split('@')[1] handleDomain = handle.split('@')[1]