alt-html-css
Bob Mottram 2020-12-16 10:30:54 +00:00
parent 77210c0f41
commit c8e9804b4a
11 changed files with 76 additions and 233 deletions

View File

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

View File

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

View File

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

View File

@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net"
__status__ = "Production"
import os
from utils import getFullDomain
from utils import removeIdEnding
from utils import isEvil
from utils import locatePost
@ -265,11 +266,7 @@ def outboxBlock(baseDir: str, httpPrefix: str,
print('WARN: unable to find nickname in ' + messageJson['object'])
return
domainBlocked, portBlocked = getDomainFromActor(messageJson['object'])
domainBlockedFull = domainBlocked
if portBlocked:
if portBlocked != 80 and portBlocked != 443:
if ':' not in domainBlocked:
domainBlockedFull = domainBlocked + ':' + str(portBlocked)
domainBlockedFull = getFullDomain(domainBlocked, portBlocked)
addBlock(baseDir, nickname, domain,
nicknameBlocked, domainBlockedFull)
@ -346,11 +343,7 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str,
return
domainObject = messageJson['object']['object']
domainBlocked, portBlocked = getDomainFromActor(domainObject)
domainBlockedFull = domainBlocked
if portBlocked:
if portBlocked != 80 and portBlocked != 443:
if ':' not in domainBlocked:
domainBlockedFull = domainBlocked + ':' + str(portBlocked)
domainBlockedFull = getFullDomain(domainBlocked, portBlocked)
removeBlock(baseDir, nickname, domain,
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 getPostAttachmentsAsHtml
from webapp_media import addEmbeddedElements
from utils import getFullDomain
from utils import getMediaFormats
from utils import getNicknameFromActor
from utils import getDomainFromActor
@ -443,10 +444,7 @@ def htmlBlogPage(authorized: bool, session,
if not timelineJson:
return blogStr + htmlFooter()
domainFull = domain
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
domainFull = getFullDomain(domain, port)
# show previous and next buttons
if pageNumber is not None:
@ -513,10 +511,7 @@ def htmlBlogPageRSS2(authorized: bool, session,
'\n' in nickname or '\r' in nickname:
return None
domainFull = domain
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
domainFull = getFullDomain(domain, port)
blogRSS2 = ''
if includeHeader:
@ -571,10 +566,7 @@ def htmlBlogPageRSS3(authorized: bool, session,
'\n' in nickname or '\r' in nickname:
return None
domainFull = domain
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
domainFull = getFullDomain(domain, port)
blogRSS3 = ''
@ -682,10 +674,7 @@ def htmlBlogView(authorized: bool,
nickname, domain, port,
noOfItems, 1)
domainFull = domain
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
domainFull = getFullDomain(domain, port)
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for acct in dirs:

View File

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

View File

@ -172,6 +172,7 @@ from shares import getSharesFeedForPerson
from shares import addShare
from shares import removeShare
from shares import expireShares
from utils import getFullDomain
from utils import removeHtml
from utils import setHashtagCategory
from utils import isEditor
@ -1501,12 +1502,7 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain
blockDomain, blockPort = \
getDomainFromActor(moderationText)
fullBlockDomain = blockDomain
if blockPort:
if blockPort != 80 and blockPort != 443:
if ':' not in blockDomain:
fullBlockDomain = \
blockDomain + ':' + str(blockPort)
fullBlockDomain = getFullDomain(blockDomain, blockPort)
if '@' in moderationText:
# nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1]
@ -1524,12 +1520,7 @@ class PubServer(BaseHTTPRequestHandler):
# https://domain
blockDomain, blockPort = \
getDomainFromActor(moderationText)
fullBlockDomain = blockDomain
if blockPort:
if blockPort != 80 and blockPort != 443:
if ':' not in blockDomain:
fullBlockDomain = \
blockDomain + ':' + str(blockPort)
fullBlockDomain = getFullDomain(blockDomain, blockPort)
if '@' in moderationText:
# nick@domain or *@domain
fullBlockDomain = moderationText.split('@')[1]
@ -1692,12 +1683,7 @@ class PubServer(BaseHTTPRequestHandler):
return
optionsDomain, optionsPort = getDomainFromActor(optionsActor)
optionsDomainFull = optionsDomain
if optionsPort:
if optionsPort != 80 and optionsPort != 443:
if ':' not in optionsDomain:
optionsDomainFull = optionsDomain + ':' + \
str(optionsPort)
optionsDomainFull = getFullDomain(optionsDomain, optionsPort)
if chooserNickname == optionsNickname and \
optionsDomain == domain and \
optionsPort == port:
@ -2011,11 +1997,7 @@ class PubServer(BaseHTTPRequestHandler):
followingNickname = getNicknameFromActor(followingActor)
followingDomain, followingPort = \
getDomainFromActor(followingActor)
followingDomainFull = followingDomain
if followingPort:
if followingPort != 80 and followingPort != 443:
followingDomainFull = \
followingDomain + ':' + str(followingPort)
followingDomainFull = getFullDomain(followingDomain, followingPort)
if followerNickname == followingNickname and \
followingDomain == domain and \
followingPort == port:
@ -2208,12 +2190,7 @@ class PubServer(BaseHTTPRequestHandler):
return
blockingDomain, blockingPort = \
getDomainFromActor(blockingActor)
blockingDomainFull = blockingDomain
if blockingPort:
if blockingPort != 80 and blockingPort != 443:
if ':' not in blockingDomain:
blockingDomainFull = \
blockingDomain + ':' + str(blockingPort)
blockingDomainFull = getFullDomain(blockingDomain, blockingPort)
if blockerNickname == blockingNickname and \
blockingDomain == domain and \
blockingPort == port:
@ -2297,12 +2274,7 @@ class PubServer(BaseHTTPRequestHandler):
return
blockingDomain, blockingPort = \
getDomainFromActor(blockingActor)
blockingDomainFull = blockingDomain
if blockingPort:
if blockingPort != 80 and blockingPort != 443:
if ':' not in blockingDomain:
blockingDomainFull = \
blockingDomain + ':' + str(blockingPort)
blockingDomainFull = getFullDomain(blockingDomain, blockingPort)
if blockerNickname == blockingNickname and \
blockingDomain == domain and \
blockingPort == port:
@ -13154,11 +13126,7 @@ def runDaemon(dormantMonths: int,
httpd.maxPostsInBox = 32000
httpd.domain = domain
httpd.port = port
httpd.domainFull = domain
if port:
if port != 80 and port != 443:
if ':' not in domain:
httpd.domainFull = domain + ':' + str(port)
httpd.domainFull = getFullDomain(domain, port)
saveDomainQrcode(baseDir, httpPrefix, httpd.domainFull)
httpd.httpPrefix = httpPrefix
httpd.debug = debug

View File

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

View File

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

View File

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

View File

@ -19,6 +19,18 @@ from calendar import monthrange
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,
dormantMonths=3) -> bool:
"""Is the given followed actor dormant, from the standpoint