Ensure port numbers are attached when needed

master
Bob Mottram 2019-08-16 21:35:11 +01:00
parent 972bceeafa
commit 707cbd7d56
20 changed files with 303 additions and 177 deletions

View File

@ -34,8 +34,10 @@ def createAcceptReject(baseDir: str,federationList: [], \
if not urlPermitted(objectJson['actor'],federationList,"inbox:write"): if not urlPermitted(objectJson['actor'],federationList,"inbox:write"):
return None return None
if port!=80 and port!=443: if port:
domain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domain=domain+':'+str(port)
newAccept = { newAccept = {
'type': acceptType, 'type': acceptType,

View File

@ -186,8 +186,10 @@ def createAnnounce(session,baseDir: str,federationList: [], \
if ':' in domain: if ':' in domain:
domain=domain.split(':')[0] domain=domain.split(':')[0]
fullDomain=domain fullDomain=domain
if port!=80 and port!=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
statusNumber,published = getStatusNumber() statusNumber,published = getStatusNumber()
newAnnounceId= \ newAnnounceId= \
@ -238,9 +240,10 @@ def announcePublic(session,baseDir: str,federationList: [], \
"""Makes a public announcement """Makes a public announcement
""" """
fromDomain=domain fromDomain=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
fromDomain=domain+':'+str(port) 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+'/followers' ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
@ -263,9 +266,10 @@ def repeatPost(session,baseDir: str,federationList: [], \
"""Repeats a given status post """Repeats a given status post
""" """
announcedDomain=announceDomain announcedDomain=announceDomain
if announcePort!=80 and announcePort!=443: if announcePort:
if ':' not in announcedDomain: if announcePort!=80 and announcePort!=443:
announcedDomain=announcedDomain+':'+str(announcePort) if ':' not in announcedDomain:
announcedDomain=announcedDomain+':'+str(announcePort)
objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \ objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \
announceNickname+'/statuses/'+str(announceStatusNumber) announceNickname+'/statuses/'+str(announceStatusNumber)
@ -297,8 +301,10 @@ def undoAnnounce(session,baseDir: str,federationList: [], \
if ':' in domain: if ':' in domain:
domain=domain.split(':')[0] domain=domain.split(':')[0]
fullDomain=domain fullDomain=domain
if port!=80 and port!=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
newUndoAnnounce = { newUndoAnnounce = {
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname, 'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
@ -343,9 +349,10 @@ def undoAnnouncePublic(session,baseDir: str,federationList: [], \
"""Undoes a public announcement """Undoes a public announcement
""" """
fromDomain=domain fromDomain=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
fromDomain=domain+':'+str(port) 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+'/followers' ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
@ -368,9 +375,10 @@ def undoRepeatPost(session,baseDir: str,federationList: [], \
"""Undoes a status post repeat """Undoes a status post repeat
""" """
announcedDomain=announceDomain announcedDomain=announceDomain
if announcePort!=80 and announcePort!=443: if announcePort:
if ':' not in announcedDomain: if announcePort!=80 and announcePort!=443:
announcedDomain=announcedDomain+':'+str(announcePort) if ':' not in announcedDomain:
announcedDomain=announcedDomain+':'+str(announcePort)
objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \ objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \
announceNickname+'/statuses/'+str(announceStatusNumber) announceNickname+'/statuses/'+str(announceStatusNumber)
@ -396,8 +404,10 @@ def sendAnnounceViaServer(session,fromNickname: str,password: str,
withDigest=True withDigest=True
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'

View File

@ -81,8 +81,10 @@ def sendAvailabilityViaServer(session,nickname: str,password: str,
return 6 return 6
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
domainFull=domain+':'+str(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+'/followers' ccUrl = httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers'

View File

@ -148,8 +148,10 @@ def sendBlockViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
@ -218,8 +220,10 @@ def sendUndoBlockViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
@ -326,7 +330,8 @@ def outboxBlock(baseDir: str,httpPrefix: str, \
domainBlockedFull=domainBlocked domainBlockedFull=domainBlocked
if portBlocked: if portBlocked:
if portBlocked!=80 and portBlocked!=443: if portBlocked!=80 and portBlocked!=443:
domainBlockedFull=domainBlocked+':'+str(portBlocked) if ':' not in domainBlocked:
domainBlockedFull=domainBlocked+':'+str(portBlocked)
addBlock(baseDir,nickname,domain, \ addBlock(baseDir,nickname,domain, \
nicknameBlocked,domainBlockedFull) nicknameBlocked,domainBlockedFull)
@ -397,7 +402,8 @@ def outboxUndoBlock(baseDir: str,httpPrefix: str, \
domainBlockedFull=domainBlocked domainBlockedFull=domainBlocked
if portBlocked: if portBlocked:
if portBlocked!=80 and portBlocked!=443: if portBlocked!=80 and portBlocked!=443:
domainBlockedFull=domainBlocked+':'+str(portBlocked) if ':' not in domainBlocked:
domainBlockedFull=domainBlocked+':'+str(portBlocked)
removeBlock(baseDir,nickname,domain, \ removeBlock(baseDir,nickname,domain, \
nicknameBlocked,domainBlockedFull) nicknameBlocked,domainBlockedFull)

View File

@ -110,8 +110,10 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
return None return None
fullDomain=domain fullDomain=domain
if port!=80 and port !=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port !=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
# make directories to store capabilities # make directories to store capabilities
ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,acceptedActor,'accept') ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,acceptedActor,'accept')
@ -169,8 +171,10 @@ def capabilitiesUpdate(baseDir: str,httpPrefix: str, \
return None return None
fullDomain=domain fullDomain=domain
if port!=80 and port !=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port !=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
# Get the filename of the capability # Get the filename of the capability
ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,updateActor,'accept') ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,updateActor,'accept')

View File

@ -2271,7 +2271,8 @@ class PubServer(BaseHTTPRequestHandler):
fullBlockDomain=blockDomain fullBlockDomain=blockDomain
if blockPort: if blockPort:
if blockPort!=80 and blockPort!=443: if blockPort!=80 and blockPort!=443:
fullBlockDomain=blockDomain+':'+str(blockPort) if ':' not in blockDomain:
fullBlockDomain=blockDomain+':'+str(blockPort)
if '@' in moderationText: if '@' in moderationText:
fullBlockDomain=moderationText.split('@')[1] fullBlockDomain=moderationText.split('@')[1]
if fullBlockDomain or nickname.startswith('#'): if fullBlockDomain or nickname.startswith('#'):
@ -2285,7 +2286,8 @@ class PubServer(BaseHTTPRequestHandler):
fullBlockDomain=blockDomain fullBlockDomain=blockDomain
if blockPort: if blockPort:
if blockPort!=80 and blockPort!=443: if blockPort!=80 and blockPort!=443:
fullBlockDomain=blockDomain+':'+str(blockPort) if ':' not in blockDomain:
fullBlockDomain=blockDomain+':'+str(blockPort)
if '@' in moderationText: if '@' in moderationText:
fullBlockDomain=moderationText.split('@')[1] fullBlockDomain=moderationText.split('@')[1]
if fullBlockDomain or nickname.startswith('#'): if fullBlockDomain or nickname.startswith('#'):
@ -2487,7 +2489,8 @@ class PubServer(BaseHTTPRequestHandler):
blockingDomainFull=blockingDomain blockingDomainFull=blockingDomain
if blockingPort: if blockingPort:
if blockingPort!=80 and blockingPort!=443: if blockingPort!=80 and blockingPort!=443:
blockingDomainFull=blockingDomain+':'+str(blockingPort) if ':' not in blockingDomain:
blockingDomainFull=blockingDomain+':'+str(blockingPort)
if blockerNickname==blockingNickname and \ if blockerNickname==blockingNickname and \
blockingDomain==self.server.domain and \ blockingDomain==self.server.domain and \
blockingPort==self.server.port: blockingPort==self.server.port:
@ -2517,7 +2520,8 @@ class PubServer(BaseHTTPRequestHandler):
blockingDomainFull=blockingDomain blockingDomainFull=blockingDomain
if blockingPort: if blockingPort:
if blockingPort!=80 and blockingPort!=443: if blockingPort!=80 and blockingPort!=443:
blockingDomainFull=blockingDomain+':'+str(blockingPort) if ':' not in blockingDomain:
blockingDomainFull=blockingDomain+':'+str(blockingPort)
if blockerNickname==blockingNickname and \ if blockerNickname==blockingNickname and \
blockingDomain==self.server.domain and \ blockingDomain==self.server.domain and \
blockingPort==self.server.port: blockingPort==self.server.port:
@ -2813,8 +2817,10 @@ def runDaemon(projectVersion, \
httpd.domain=domain httpd.domain=domain
httpd.port=port httpd.port=port
httpd.domainFull=domain httpd.domainFull=domain
if port!=80 and port!=443: if port:
httpd.domainFull=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
httpd.domainFull=domain+':'+str(port)
httpd.httpPrefix=httpPrefix httpd.httpPrefix=httpPrefix
httpd.debug=debug httpd.debug=debug
httpd.federationList=fedList.copy() httpd.federationList=fedList.copy()

View File

@ -42,8 +42,10 @@ 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!=80 and port!=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
statusNumber,published = getStatusNumber() statusNumber,published = getStatusNumber()
newDeleteId= \ newDeleteId= \
@ -91,8 +93,10 @@ def sendDeleteViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
@ -157,9 +161,10 @@ def deletePublic(session,baseDir: str,federationList: [], \
"""Makes a public delete activity """Makes a public delete activity
""" """
fromDomain=domain fromDomain=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
fromDomain=domain+':'+str(port) 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+'/followers' ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
@ -182,9 +187,10 @@ def deletePostPub(session,baseDir: str,federationList: [], \
"""Deletes a given status post """Deletes a given status post
""" """
deletedDomain=deleteDomain deletedDomain=deleteDomain
if deletePort!=80 and deletePort!=443: if deletePort:
if ':' not in deletedDomain: if deletePort!=80 and deletePort!=443:
deletedDomain=deletedDomain+':'+str(deletePort) if ':' not in deletedDomain:
deletedDomain=deletedDomain+':'+str(deletePort)
objectUrl = deleteHttpsPrefix + '://'+deletedDomain+'/users/'+ \ objectUrl = deleteHttpsPrefix + '://'+deletedDomain+'/users/'+ \
deleteNickname+'/statuses/'+str(deleteStatusNumber) deleteNickname+'/statuses/'+str(deleteStatusNumber)

View File

@ -42,7 +42,8 @@ def isFollowingActor(baseDir: str,nickname: str,domain: str,actor: str) -> bool:
followerHandle=followerNickname+'@'+followerDomain followerHandle=followerNickname+'@'+followerDomain
if followerPort: if followerPort:
if followerPort!=80 and followerPort!=443: if followerPort!=80 and followerPort!=443:
followerHandle+=':'+str(followerPort) if ':' not in followerHandle:
followerHandle+=':'+str(followerPort)
if followerHandle in open(followersFile).read(): if followerHandle in open(followersFile).read():
return True return True
return False return False
@ -207,9 +208,11 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
return None return None
if not validNickname(nickname): if not validNickname(nickname):
return None return None
if port!=80 and port!=443: if port:
domain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domain=domain+':'+str(port)
if headerOnly: if headerOnly:
following = { following = {
@ -298,11 +301,12 @@ def storeFollowRequest(baseDir: str, \
accountsDir=baseDir+'/accounts/'+nicknameToFollow+'@'+domainToFollow accountsDir=baseDir+'/accounts/'+nicknameToFollow+'@'+domainToFollow
if not os.path.isdir(accountsDir): if not os.path.isdir(accountsDir):
return False return False
if port!=80 and port!=443: approveHandle=nickname+'@'+domain
approveHandle=nickname+'@'+domain+':'+str(fromPort) if fromPort:
else: if fromPort!=80 and fromPort!=443:
approveHandle=nickname+'@'+domain if ':' not in domain:
approveHandle=nickname+'@'+domain+':'+str(fromPort)
# add to a file which contains a list of requests # add to a file which contains a list of requests
approveFollowsFilename=accountsDir+'/followrequests.txt' approveFollowsFilename=accountsDir+'/followrequests.txt'
@ -353,7 +357,8 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
if tempPort: if tempPort:
fromPort=tempPort fromPort=tempPort
if tempPort!=80 and tempPort!=443: if tempPort!=80 and tempPort!=443:
domainFull=domain+':'+str(tempPort) 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)
@ -378,7 +383,8 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
domainToFollowFull=domainToFollow domainToFollowFull=domainToFollow
if tempPort: if tempPort:
if tempPort!=80 and tempPort!=443: if tempPort!=80 and tempPort!=443:
domainToFollowFull=domainToFollow+':'+str(tempPort) 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:
@ -466,14 +472,18 @@ def sendFollowRequest(session,baseDir: str, \
return None return None
fullDomain=domain fullDomain=domain
followActor=httpPrefix+'://'+domain+'/users/'+nickname followActor=httpPrefix+'://'+domain+'/users/'+nickname
if port!=80 and port!=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port!=443:
followActor=httpPrefix+'://'+domain+':'+str(port)+'/users/'+nickname if ':' not in domain:
fullDomain=domain+':'+str(port)
followActor=httpPrefix+'://'+domain+':'+str(port)+'/users/'+nickname
requestDomain=followDomain requestDomain=followDomain
if followPort!=80 and followPort!=443: if followPort:
requestDomain=followDomain+':'+str(followPort) if followPort!=80 and followPort!=443:
if ':' not in followDomain:
requestDomain=followDomain+':'+str(followPort)
statusNumber,published = getStatusNumber() statusNumber,published = getStatusNumber()
@ -511,12 +521,16 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(fromPort) if fromPort!=80 and fromPort!=443:
if ':' not in fromDomain:
fromDomainFull=fromDomain+':'+str(fromPort)
followDomainFull=followDomain followDomainFull=followDomain
if followPort!=80 and followPort!=443: if followPort:
followDomainFull=followDomain+':'+str(followPort) if followPort!=80 and followPort!=443:
if ':' not in followDomain:
followDomainFull=followDomain+':'+str(followPort)
followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
@ -587,11 +601,15 @@ def sendUnfollowRequestViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(fromPort) if fromPort!=80 and fromPort!=443:
if ':' not in fromDomain:
fromDomainFull=fromDomain+':'+str(fromPort)
followDomainFull=followDomain followDomainFull=followDomain
if followPort!=80 and followPort!=443: if followPort:
followDomainFull=followDomain+':'+str(followPort) if followPort!=80 and followPort!=443:
if ':' not in followDomain:
followDomainFull=followDomain+':'+str(followPort)
followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
@ -745,14 +763,16 @@ def outboxUndoFollow(baseDir: str,messageJson: {},debug: bool) -> None:
domainFollowerFull=domainFollower domainFollowerFull=domainFollower
if portFollower: if portFollower:
if portFollower!=80 and portFollower!=443: if portFollower!=80 and portFollower!=443:
domainFollowerFull=domainFollower+':'+str(portFollower) if ':' not in domainFollower:
domainFollowerFull=domainFollower+':'+str(portFollower)
nicknameFollowing=getNicknameFromActor(messageJson['object']['object']) nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object']) domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object'])
domainFollowingFull=domainFollowing domainFollowingFull=domainFollowing
if portFollowing: if portFollowing:
if portFollowing!=80 and portFollowing!=443: if portFollowing!=80 and portFollowing!=443:
domainFollowingFull=domainFollowing+':'+str(portFollowing) if ':' not in domainFollowing:
domainFollowingFull=domainFollowing+':'+str(portFollowing)
if unfollowPerson(baseDir,nicknameFollower,domainFollowerFull, \ if unfollowPerson(baseDir,nicknameFollower,domainFollowerFull, \
nicknameFollowing,domainFollowingFull): nicknameFollowing,domainFollowingFull):

View File

@ -187,7 +187,8 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str
return None return None
if postPort: if postPort:
if postPort!=80 and postPort!=443: if postPort!=80 and postPort!=443:
postDomain=postDomain+':'+str(postPort) 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):
@ -368,8 +369,10 @@ def inboxPostRecipients(baseDir :str,postJsonObject :{},httpPrefix :str,domain :
if ':' in domain: if ':' in domain:
domain=domain.split(':')[0] domain=domain.split(':')[0]
domainBase=domain domainBase=domain
if port!=80 and port!=443: if port:
domain=domain+':'+str(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']
@ -485,14 +488,16 @@ def receiveUndoFollow(session,baseDir: str,httpPrefix: str, \
domainFollowerFull=domainFollower domainFollowerFull=domainFollower
if portFollower: if portFollower:
if portFollower!=80 and portFollower!=443: if portFollower!=80 and portFollower!=443:
domainFollowerFull=domainFollower+':'+str(portFollower) if ':' not in domainFollower:
domainFollowerFull=domainFollower+':'+str(portFollower)
nicknameFollowing=getNicknameFromActor(messageJson['object']['object']) nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object']) domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object'])
domainFollowingFull=domainFollowing domainFollowingFull=domainFollowing
if portFollowing: if portFollowing:
if portFollowing!=80 and portFollowing!=443: if portFollowing!=80 and portFollowing!=443:
domainFollowingFull=domainFollowing+':'+str(portFollowing) if ':' not in domainFollowing:
domainFollowingFull=domainFollowing+':'+str(portFollowing)
if unfollowerOfPerson(baseDir, \ if unfollowerOfPerson(baseDir, \
nicknameFollowing,domainFollowingFull, \ nicknameFollowing,domainFollowingFull, \
@ -719,7 +724,8 @@ def receiveDelete(session,handle: str,baseDir: str, \
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) 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 \

57
like.py
View File

@ -137,9 +137,10 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port:
return None return None
fullDomain=domain fullDomain=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
fullDomain=domain+':'+str(port) if ':' not in domain:
fullDomain=domain+':'+str(port)
likeTo=[] likeTo=[]
if '/statuses/' in objectUrl: if '/statuses/' in objectUrl:
@ -196,18 +197,20 @@ def likePost(session,baseDir: str,federationList: [], \
"""Likes a given status post """Likes a given status post
""" """
likeDomain=likeDomain likeDomain=likeDomain
if likePort!=80 and likePort!=443: if likePort:
if ':' not in likeDomain: if likePort!=80 and likePort!=443:
likeDomain=likeDomain+':'+str(likePort) if ':' not in likeDomain:
likeDomain=likeDomain+':'+str(likePort)
objectUrl = \ objectUrl = \
httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \ httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \
'/statuses/'+str(likeStatusNumber) '/statuses/'+str(likeStatusNumber)
if likePort!=80 and likePort!=443: ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname if likePort:
else: if likePort!=80 and likePort!=443:
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname if ':' not in likeDomain:
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
return like(session,baseDir,federationList,nickname,domain,port, \ return like(session,baseDir,federationList,nickname,domain,port, \
ccList,httpPrefix,objectUrl,clientToServer, \ ccList,httpPrefix,objectUrl,clientToServer, \
@ -227,9 +230,10 @@ def undolike(session,baseDir: str,federationList: [],nickname: str,domain: str,p
return None return None
fullDomain=domain fullDomain=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
fullDomain=domain+':'+str(port) if ':' not in domain:
fullDomain=domain+':'+str(port)
likeTo=[] likeTo=[]
if '/statuses/' in objectUrl: if '/statuses/' in objectUrl:
@ -291,17 +295,20 @@ def undoLikePost(session,baseDir: str,federationList: [], \
"""Removes a liked post """Removes a liked post
""" """
likeDomain=likeDomain likeDomain=likeDomain
if likePort!=80 and likePort!=443: if likePort:
likeDomain=likeDomain+':'+str(likePort) if likePort!=80 and likePort!=443:
if ':' not in likeDomain:
likeDomain=likeDomain+':'+str(likePort)
objectUrl = \ objectUrl = \
httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \ httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \
'/statuses/'+str(likeStatusNumber) '/statuses/'+str(likeStatusNumber)
if likePort!=80 and likePort!=443: ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname if likePort:
else: if likePort!=80 and likePort!=443:
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname if ':' not in likeDomain:
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
return undoLike(session,baseDir,federationList,nickname,domain,port, \ return undoLike(session,baseDir,federationList,nickname,domain,port, \
ccList,httpPrefix,objectUrl,clientToServer, \ ccList,httpPrefix,objectUrl,clientToServer, \
@ -319,8 +326,10 @@ def sendLikeViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
@ -391,8 +400,10 @@ def sendUndoLikeViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'

View File

@ -67,9 +67,10 @@ def attachImage(baseDir: str,httpPrefix: str,domain: str,port: int, \
mediaType='image/gif' mediaType='image/gif'
fileExtension='gif' fileExtension='gif'
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domain=domain+':'+str(port) if ':' not in domain:
domain=domain+':'+str(port)
mPath=getMediaPath() mPath=getMediaPath()
mediaPath=mPath+'/'+createPassword(32)+'.'+fileExtension mediaPath=mPath+'/'+createPassword(32)+'.'+fileExtension

View File

@ -56,8 +56,10 @@ 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=domain
if port!=80 and port!=443: if port:
fullDomain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
fullDomain=domain+':'+str(port)
handle=nickname.lower()+'@'+domain.lower() handle=nickname.lower()+'@'+domain.lower()
personFilename=baseDir+'/accounts/'+handle+'.json' personFilename=baseDir+'/accounts/'+handle+'.json'
@ -135,8 +137,10 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
storeWebfingerEndpoint(nickname,domain,port,baseDir,webfingerEndpoint) storeWebfingerEndpoint(nickname,domain,port,baseDir,webfingerEndpoint)
handle=nickname.lower()+'@'+domain.lower() handle=nickname.lower()+'@'+domain.lower()
if port!=80 and port!=443: if port:
domain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domain=domain+':'+str(port)
newPerson = {'@context': ['https://www.w3.org/ns/activitystreams', newPerson = {'@context': ['https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
@ -545,7 +549,8 @@ def canRemovePost(baseDir: str,nickname: str,domain: str,port: int,postId: str)
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) 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')
@ -570,7 +575,8 @@ def removeTagsForNickname(baseDir: str,nickname: str,domain: str,port: int) -> N
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) 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.listdir(directory): for f in os.listdir(directory):

View File

@ -431,9 +431,10 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
tags=[] tags=[]
hashtagsDict={} hashtagsDict={}
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domain=domain+':'+str(port) if ':' not in domain:
domain=domain+':'+str(port)
# convert content to html # convert content to html
content= \ content= \
@ -604,9 +605,10 @@ def outboxMessageCreateWrap(httpPrefix: str, \
https://www.w3.org/TR/activitypub/#object-without-create https://www.w3.org/TR/activitypub/#object-without-create
""" """
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domain=domain+':'+str(port) 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']
@ -638,8 +640,10 @@ 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!=80 and port!=443: if port:
domain=domain+':'+str(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
@ -699,9 +703,10 @@ def createPublicPost(baseDir: str,
"""Public post """Public post
""" """
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domainFull=domain+':'+str(port) 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/'+nickname+'/followers', \ httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
@ -719,9 +724,10 @@ def createUnlistedPost(baseDir: str,
"""Unlisted post. This has the #Public and followers links inverted. """Unlisted post. This has the #Public and followers links inverted.
""" """
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domainFull=domain+':'+str(port) if ':' not in domain:
domainFull=domain+':'+str(port)
return createPostBase(baseDir,nickname, domain, port, \ return createPostBase(baseDir,nickname, domain, port, \
httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \ httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
'https://www.w3.org/ns/activitystreams#Public', \ 'https://www.w3.org/ns/activitystreams#Public', \
@ -739,9 +745,10 @@ def createFollowersOnlyPost(baseDir: str,
"""Followers only post """Followers only post
""" """
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domainFull=domain+':'+str(port) if ':' not in domain:
domainFull=domain+':'+str(port)
return createPostBase(baseDir,nickname, domain, port, \ return createPostBase(baseDir,nickname, domain, port, \
httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \ httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
None, None,
@ -810,7 +817,8 @@ def createReportPost(baseDir: str,
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) 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'
@ -917,9 +925,10 @@ def sendPost(projectVersion: str, \
""" """
withDigest=True withDigest=True
if toPort!=80 and toPort!=443: if toPort:
if ':' not in toDomain: if toPort!=80 and toPort!=443:
toDomain=toDomain+':'+str(toPort) if ':' not in toDomain:
toDomain=toDomain+':'+str(toPort)
handle=httpPrefix+'://'+toDomain+'/@'+toNickname handle=httpPrefix+'://'+toDomain+'/@'+toNickname
@ -1010,9 +1019,10 @@ def sendPostViaServer(projectVersion: str, \
return 6 return 6
withDigest=True withDigest=True
if toPort!=80 and toPort!=443: if toPort:
if ':' not in fromDomain: if toPort!=80 and toPort!=443:
fromDomain=fromDomain+':'+str(fromPort) if ':' not in fromDomain:
fromDomain=fromDomain+':'+str(fromPort)
handle=httpPrefix+'://'+fromDomain+'/@'+fromNickname handle=httpPrefix+'://'+fromDomain+'/@'+fromNickname
@ -1049,7 +1059,8 @@ def sendPostViaServer(projectVersion: str, \
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort: if fromPort:
if fromPort!=80 and fromPort!=443: if fromPort!=80 and fromPort!=443:
fromDomainFull=fromDomain+':'+str(fromPort) if ':' not in fromDomain:
fromDomainFull=fromDomain+':'+str(fromPort)
cc=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers' cc=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
else: else:
if toDomain.lower().endswith('followers') or \ if toDomain.lower().endswith('followers') or \
@ -1057,8 +1068,10 @@ def sendPostViaServer(projectVersion: str, \
toPersonId=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers' toPersonId=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
else: else:
toDomainFull=toDomain toDomainFull=toDomain
if toPort!=80 and toDomain!=443: if toPort:
toDomainFull=toDomain+':'+str(toPort) if toPort!=80 and toPort!=443:
if ':' not in toDomain:
toDomainFull=toDomain+':'+str(toPort)
toPersonId=httpPrefix+'://'+toDomainFull+'/users/'+toNickname toPersonId=httpPrefix+'://'+toDomainFull+'/users/'+toNickname
postJsonObject = \ postJsonObject = \
createPostBase(baseDir, \ createPostBase(baseDir, \
@ -1273,11 +1286,13 @@ def sendToNamedAddresses(session,baseDir: str, \
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) if ':' not in domain:
domainFull=domain+':'+str(port)
toDomainFull=toDomain toDomainFull=toDomain
if toPort: if toPort:
if toPort!=80 and toPort!=443: if toPort!=80 and toPort!=443:
toDomainFull=toDomain+':'+str(toPort) if ':' not in toDomain:
toDomainFull=toDomain+':'+str(toPort)
print('DEBUG: Post sending s2s: '+nickname+'@'+domainFull+' to '+toNickname+'@'+toDomainFull) print('DEBUG: Post sending s2s: '+nickname+'@'+domainFull+' to '+toNickname+'@'+toDomainFull)
cc=[] cc=[]
sendSignedJson(postJsonObject,session,baseDir, \ sendSignedJson(postJsonObject,session,baseDir, \
@ -1359,8 +1374,10 @@ def createModeration(baseDir: str,nickname: str,domain: str,port: int,httpPrefix
boxDir = createPersonDir(nickname,domain,baseDir,'inbox') boxDir = createPersonDir(nickname,domain,baseDir,'inbox')
boxname='moderation' boxname='moderation'
if port!=80 and port!=443: if port:
domain = domain+':'+str(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
@ -1433,8 +1450,10 @@ def createBoxBase(baseDir: str,boxname: str, \
if boxname=='inbox': if boxname=='inbox':
sharedBoxDir = createPersonDir('inbox',domain,baseDir,boxname) sharedBoxDir = createPersonDir('inbox',domain,baseDir,boxname)
if port!=80 and port!=443: if port:
domain = domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domain=domain+':'+str(port)
pageStr='?page=true' pageStr='?page=true'
if pageNumber: if pageNumber:
@ -1660,8 +1679,10 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \
federationList=[] federationList=[]
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
domainFull=domain+':'+str(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, \

View File

@ -183,7 +183,8 @@ def outboxDelegate(baseDir: str,authenticatedNickname: str,messageJson: {},debug
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) if ':' not in domain:
domainFull=domain+':'+str(port)
role=messageJson['object']['object'].split(';')[1].strip().lower() role=messageJson['object']['object'].split(';')[1].strip().lower()
if not role: if not role:
@ -216,8 +217,10 @@ def sendRoleViaServer(session,delegatorNickname: str,password: str,
return 6 return 6
delegatorDomainFull=delegatorDomain delegatorDomainFull=delegatorDomain
if fromPort!=80 and fromPort!=443: if fromPort:
delegatorDomainFull=delegatorDomain+':'+str(fromPort) if fromPort!=80 and fromPort!=443:
if ':' not in delegatorDomain:
delegatorDomainFull=delegatorDomain+':'+str(fromPort)
toUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+nickname toUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+nickname
ccUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+delegatorNickname+'/followers' ccUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+delegatorNickname+'/followers'

View File

@ -101,8 +101,10 @@ def addShare(baseDir: str, \
if imageFilename: if imageFilename:
if os.path.isfile(imageFilename): if os.path.isfile(imageFilename):
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
domainFull=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domainFull=domain+':'+str(port)
if not os.path.isdir(baseDir+'/sharefiles'): if not os.path.isdir(baseDir+'/sharefiles'):
os.mkdir(baseDir+'/sharefiles') os.mkdir(baseDir+'/sharefiles')
if not os.path.isdir(baseDir+'/sharefiles/'+nickname): if not os.path.isdir(baseDir+'/sharefiles/'+nickname):
@ -203,8 +205,10 @@ def getSharesFeedForPerson(baseDir: str, \
if not validNickname(nickname): if not validNickname(nickname):
return None return None
if port!=80 and port!=443: if port:
domain=domain+':'+str(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:
@ -283,8 +287,10 @@ def sendShareViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
@ -370,8 +376,10 @@ def sendUndoShareViaServer(session,fromNickname: str,password: str,
return 6 return 6
fromDomainFull=fromDomain fromDomainFull=fromDomain
if fromPort!=80 and fromPort!=443: if fromPort:
fromDomainFull=fromDomain+':'+str(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+'/followers' ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'

View File

@ -98,8 +98,10 @@ def sendSkillViaServer(session,nickname: str,password: str,
return 6 return 6
domainFull=domain domainFull=domain
if port!=80 and port!=443: if port:
domainFull=domain+':'+str(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+'/followers' ccUrl = httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers'

View File

@ -88,8 +88,10 @@ def testHttpsigBase(withDigest):
messageBodyJsonStr=json.dumps(messageBodyJson) messageBodyJsonStr=json.dumps(messageBodyJson)
headersDomain=domain headersDomain=domain
if port!=80 and port !=443: if port:
headersDomain=domain+':'+str(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'

View File

@ -156,9 +156,10 @@ def removeAttachment(baseDir: str,httpPrefix: str,domain: str,postJson: {}):
return return
if not postJson['attachment'][0].get('url'): if not postJson['attachment'][0].get('url'):
return return
if port!=80 and port!=443: if port:
if ':' not in domain: if port!=80 and port!=443:
domain=domain+':'+str(port) if ':' not in domain:
domain=domain+':'+str(port)
attachmentUrl=postJson['attachment'][0]['url'] attachmentUrl=postJson['attachment'][0]['url']
if not attachmentUrl: if not attachmentUrl:
return return

View File

@ -79,8 +79,10 @@ def storeWebfingerEndpoint(nickname: str,domain: str,port: int,baseDir: str, \
wfJson: {}) -> bool: wfJson: {}) -> bool:
"""Stores webfinger endpoint for a user to a file """Stores webfinger endpoint for a user to a file
""" """
if port!=80 and port!=443: if port:
domain=domain+':'+str(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):
@ -95,8 +97,10 @@ 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!=80 and port!=443: if port:
domain=domain+':'+str(port) if port!=80 and port!=443:
if ':' not in domain:
domain=domain+':'+str(port)
account = { account = {
"aliases": [ "aliases": [
@ -178,9 +182,10 @@ def webfingerLookup(path: str,baseDir: str,port: int,debug: bool) -> {}:
if debug: if debug:
print('DEBUG: WEBFINGER no @ in handle '+handle) print('DEBUG: WEBFINGER no @ in handle '+handle)
return None return None
if port!=80 and port !=443: if port:
if ':' not in handle: if port!=80 and port !=443:
handle=handle+':'+str(port) if ':' not in handle:
handle=handle+':'+str(port)
filename=baseDir+'/wfendpoints/'+handle.lower()+'.json' filename=baseDir+'/wfendpoints/'+handle.lower()+'.json'
if debug: if debug:
print('DEBUG: WEBFINGER filename '+filename) print('DEBUG: WEBFINGER filename '+filename)

View File

@ -225,7 +225,8 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str:
domainFull=domain domainFull=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
domainFull=domain+':'+str(port) if ':' not in domain:
domainFull=domain+':'+str(port)
actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json' actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json'
if not os.path.isfile(actorFilename): if not os.path.isfile(actorFilename):
@ -1013,7 +1014,8 @@ def individualPostAsHtml(baseDir: str, \
fullDomain=domain fullDomain=domain
if port: if port:
if port!=80 and port!=443: if port!=80 and port!=443:
fullDomain=domain+':'+str(port) if ':' not in domain:
fullDomain=domain+':'+str(port)
if fullDomain not in postJsonObject['actor']: if fullDomain not in postJsonObject['actor']:
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \ inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \
@ -1040,7 +1042,8 @@ def individualPostAsHtml(baseDir: str, \
actorDomainFull=actorDomain actorDomainFull=actorDomain
if actorPort: if actorPort:
if actorPort!=80 and actorPort!=443: if actorPort!=80 and actorPort!=443:
actorDomainFull=actorDomain+':'+str(actorPort) if ':' not in actorDomain:
actorDomainFull=actorDomain+':'+str(actorPort)
if isBlocked(baseDir,nickname,domain,actorNickname,actorDomainFull): if isBlocked(baseDir,nickname,domain,actorNickname,actorDomainFull):
blockUnblockStr='<a href="/users/'+nickname+'?unblock='+postJsonObject['actor']+';'+avatarUrl+'">Unblock</a>' blockUnblockStr='<a href="/users/'+nickname+'?unblock='+postJsonObject['actor']+';'+avatarUrl+'">Unblock</a>'
@ -1520,7 +1523,8 @@ def htmlProfileAfterSearch(baseDir: str,path: str,httpPrefix: str, \
searchDomainFull=searchDomain searchDomainFull=searchDomain
if searchPort: if searchPort:
if searchPort!=80 and searchPort!=443: if searchPort!=80 and searchPort!=443:
searchDomainFull=searchDomain+':'+str(searchPort) if ':' not in searchDomain:
searchDomainFull=searchDomain+':'+str(searchPort)
profileStr='' profileStr=''
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: