mirror of https://gitlab.com/bashrc2/epicyon
Ensure port numbers are attached when needed
parent
972bceeafa
commit
707cbd7d56
|
@ -34,8 +34,10 @@ def createAcceptReject(baseDir: str,federationList: [], \
|
|||
if not urlPermitted(objectJson['actor'],federationList,"inbox:write"):
|
||||
return None
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
newAccept = {
|
||||
'type': acceptType,
|
||||
|
|
46
announce.py
46
announce.py
|
@ -186,8 +186,10 @@ def createAnnounce(session,baseDir: str,federationList: [], \
|
|||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
statusNumber,published = getStatusNumber()
|
||||
newAnnounceId= \
|
||||
|
@ -238,9 +240,10 @@ def announcePublic(session,baseDir: str,federationList: [], \
|
|||
"""Makes a public announcement
|
||||
"""
|
||||
fromDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fromDomain=domain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
|
||||
|
@ -263,9 +266,10 @@ def repeatPost(session,baseDir: str,federationList: [], \
|
|||
"""Repeats a given status post
|
||||
"""
|
||||
announcedDomain=announceDomain
|
||||
if announcePort!=80 and announcePort!=443:
|
||||
if ':' not in announcedDomain:
|
||||
announcedDomain=announcedDomain+':'+str(announcePort)
|
||||
if announcePort:
|
||||
if announcePort!=80 and announcePort!=443:
|
||||
if ':' not in announcedDomain:
|
||||
announcedDomain=announcedDomain+':'+str(announcePort)
|
||||
|
||||
objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \
|
||||
announceNickname+'/statuses/'+str(announceStatusNumber)
|
||||
|
@ -297,8 +301,10 @@ def undoAnnounce(session,baseDir: str,federationList: [], \
|
|||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
newUndoAnnounce = {
|
||||
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
|
||||
|
@ -343,9 +349,10 @@ def undoAnnouncePublic(session,baseDir: str,federationList: [], \
|
|||
"""Undoes a public announcement
|
||||
"""
|
||||
fromDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fromDomain=domain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
|
||||
|
@ -368,9 +375,10 @@ def undoRepeatPost(session,baseDir: str,federationList: [], \
|
|||
"""Undoes a status post repeat
|
||||
"""
|
||||
announcedDomain=announceDomain
|
||||
if announcePort!=80 and announcePort!=443:
|
||||
if ':' not in announcedDomain:
|
||||
announcedDomain=announcedDomain+':'+str(announcePort)
|
||||
if announcePort:
|
||||
if announcePort!=80 and announcePort!=443:
|
||||
if ':' not in announcedDomain:
|
||||
announcedDomain=announcedDomain+':'+str(announcePort)
|
||||
|
||||
objectUrl = announceHttpsPrefix + '://'+announcedDomain+'/users/'+ \
|
||||
announceNickname+'/statuses/'+str(announceStatusNumber)
|
||||
|
@ -396,8 +404,10 @@ def sendAnnounceViaServer(session,fromNickname: str,password: str,
|
|||
withDigest=True
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
|
|
@ -81,8 +81,10 @@ def sendAvailabilityViaServer(session,nickname: str,password: str,
|
|||
return 6
|
||||
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
|
||||
toUrl = httpPrefix+'://'+domainFull+'/users/'+nickname
|
||||
ccUrl = httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers'
|
||||
|
|
18
blocking.py
18
blocking.py
|
@ -148,8 +148,10 @@ def sendBlockViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
@ -218,8 +220,10 @@ def sendUndoBlockViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
@ -326,7 +330,8 @@ def outboxBlock(baseDir: str,httpPrefix: str, \
|
|||
domainBlockedFull=domainBlocked
|
||||
if portBlocked:
|
||||
if portBlocked!=80 and portBlocked!=443:
|
||||
domainBlockedFull=domainBlocked+':'+str(portBlocked)
|
||||
if ':' not in domainBlocked:
|
||||
domainBlockedFull=domainBlocked+':'+str(portBlocked)
|
||||
|
||||
addBlock(baseDir,nickname,domain, \
|
||||
nicknameBlocked,domainBlockedFull)
|
||||
|
@ -397,7 +402,8 @@ def outboxUndoBlock(baseDir: str,httpPrefix: str, \
|
|||
domainBlockedFull=domainBlocked
|
||||
if portBlocked:
|
||||
if portBlocked!=80 and portBlocked!=443:
|
||||
domainBlockedFull=domainBlocked+':'+str(portBlocked)
|
||||
if ':' not in domainBlocked:
|
||||
domainBlockedFull=domainBlocked+':'+str(portBlocked)
|
||||
|
||||
removeBlock(baseDir,nickname,domain, \
|
||||
nicknameBlocked,domainBlockedFull)
|
||||
|
|
|
@ -110,8 +110,10 @@ def capabilitiesAccept(baseDir: str,httpPrefix: str, \
|
|||
return None
|
||||
|
||||
fullDomain=domain
|
||||
if port!=80 and port !=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port !=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
# make directories to store capabilities
|
||||
ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,acceptedActor,'accept')
|
||||
|
@ -169,8 +171,10 @@ def capabilitiesUpdate(baseDir: str,httpPrefix: str, \
|
|||
return None
|
||||
|
||||
fullDomain=domain
|
||||
if port!=80 and port !=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port !=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
# Get the filename of the capability
|
||||
ocapFilename=getOcapFilename(baseDir,nickname,fullDomain,updateActor,'accept')
|
||||
|
|
18
daemon.py
18
daemon.py
|
@ -2271,7 +2271,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fullBlockDomain=blockDomain
|
||||
if blockPort:
|
||||
if blockPort!=80 and blockPort!=443:
|
||||
fullBlockDomain=blockDomain+':'+str(blockPort)
|
||||
if ':' not in blockDomain:
|
||||
fullBlockDomain=blockDomain+':'+str(blockPort)
|
||||
if '@' in moderationText:
|
||||
fullBlockDomain=moderationText.split('@')[1]
|
||||
if fullBlockDomain or nickname.startswith('#'):
|
||||
|
@ -2285,7 +2286,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fullBlockDomain=blockDomain
|
||||
if blockPort:
|
||||
if blockPort!=80 and blockPort!=443:
|
||||
fullBlockDomain=blockDomain+':'+str(blockPort)
|
||||
if ':' not in blockDomain:
|
||||
fullBlockDomain=blockDomain+':'+str(blockPort)
|
||||
if '@' in moderationText:
|
||||
fullBlockDomain=moderationText.split('@')[1]
|
||||
if fullBlockDomain or nickname.startswith('#'):
|
||||
|
@ -2487,7 +2489,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
blockingDomainFull=blockingDomain
|
||||
if blockingPort:
|
||||
if blockingPort!=80 and blockingPort!=443:
|
||||
blockingDomainFull=blockingDomain+':'+str(blockingPort)
|
||||
if ':' not in blockingDomain:
|
||||
blockingDomainFull=blockingDomain+':'+str(blockingPort)
|
||||
if blockerNickname==blockingNickname and \
|
||||
blockingDomain==self.server.domain and \
|
||||
blockingPort==self.server.port:
|
||||
|
@ -2517,7 +2520,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
blockingDomainFull=blockingDomain
|
||||
if blockingPort:
|
||||
if blockingPort!=80 and blockingPort!=443:
|
||||
blockingDomainFull=blockingDomain+':'+str(blockingPort)
|
||||
if ':' not in blockingDomain:
|
||||
blockingDomainFull=blockingDomain+':'+str(blockingPort)
|
||||
if blockerNickname==blockingNickname and \
|
||||
blockingDomain==self.server.domain and \
|
||||
blockingPort==self.server.port:
|
||||
|
@ -2813,8 +2817,10 @@ def runDaemon(projectVersion, \
|
|||
httpd.domain=domain
|
||||
httpd.port=port
|
||||
httpd.domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
httpd.domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
httpd.domainFull=domain+':'+str(port)
|
||||
httpd.httpPrefix=httpPrefix
|
||||
httpd.debug=debug
|
||||
httpd.federationList=fedList.copy()
|
||||
|
|
26
delete.py
26
delete.py
|
@ -42,8 +42,10 @@ def createDelete(session,baseDir: str,federationList: [], \
|
|||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
statusNumber,published = getStatusNumber()
|
||||
newDeleteId= \
|
||||
|
@ -91,8 +93,10 @@ def sendDeleteViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
@ -157,9 +161,10 @@ def deletePublic(session,baseDir: str,federationList: [], \
|
|||
"""Makes a public delete activity
|
||||
"""
|
||||
fromDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fromDomain=domain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomain+'/users/'+nickname+'/followers'
|
||||
|
@ -182,9 +187,10 @@ def deletePostPub(session,baseDir: str,federationList: [], \
|
|||
"""Deletes a given status post
|
||||
"""
|
||||
deletedDomain=deleteDomain
|
||||
if deletePort!=80 and deletePort!=443:
|
||||
if ':' not in deletedDomain:
|
||||
deletedDomain=deletedDomain+':'+str(deletePort)
|
||||
if deletePort:
|
||||
if deletePort!=80 and deletePort!=443:
|
||||
if ':' not in deletedDomain:
|
||||
deletedDomain=deletedDomain+':'+str(deletePort)
|
||||
|
||||
objectUrl = deleteHttpsPrefix + '://'+deletedDomain+'/users/'+ \
|
||||
deleteNickname+'/statuses/'+str(deleteStatusNumber)
|
||||
|
|
74
follow.py
74
follow.py
|
@ -42,7 +42,8 @@ def isFollowingActor(baseDir: str,nickname: str,domain: str,actor: str) -> bool:
|
|||
followerHandle=followerNickname+'@'+followerDomain
|
||||
if followerPort:
|
||||
if followerPort!=80 and followerPort!=443:
|
||||
followerHandle+=':'+str(followerPort)
|
||||
if ':' not in followerHandle:
|
||||
followerHandle+=':'+str(followerPort)
|
||||
if followerHandle in open(followersFile).read():
|
||||
return True
|
||||
return False
|
||||
|
@ -207,9 +208,11 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str, \
|
|||
return None
|
||||
if not validNickname(nickname):
|
||||
return None
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
if headerOnly:
|
||||
following = {
|
||||
|
@ -298,11 +301,12 @@ def storeFollowRequest(baseDir: str, \
|
|||
accountsDir=baseDir+'/accounts/'+nicknameToFollow+'@'+domainToFollow
|
||||
if not os.path.isdir(accountsDir):
|
||||
return False
|
||||
|
||||
if port!=80 and port!=443:
|
||||
approveHandle=nickname+'@'+domain+':'+str(fromPort)
|
||||
else:
|
||||
approveHandle=nickname+'@'+domain
|
||||
|
||||
approveHandle=nickname+'@'+domain
|
||||
if fromPort:
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
if ':' not in domain:
|
||||
approveHandle=nickname+'@'+domain+':'+str(fromPort)
|
||||
|
||||
# add to a file which contains a list of requests
|
||||
approveFollowsFilename=accountsDir+'/followrequests.txt'
|
||||
|
@ -353,7 +357,8 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
|
|||
if tempPort:
|
||||
fromPort=tempPort
|
||||
if tempPort!=80 and tempPort!=443:
|
||||
domainFull=domain+':'+str(tempPort)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(tempPort)
|
||||
if not domainPermitted(domain,federationList):
|
||||
if debug:
|
||||
print('DEBUG: follower from domain not permitted - '+domain)
|
||||
|
@ -378,7 +383,8 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \
|
|||
domainToFollowFull=domainToFollow
|
||||
if tempPort:
|
||||
if tempPort!=80 and tempPort!=443:
|
||||
domainToFollowFull=domainToFollow+':'+str(tempPort)
|
||||
if ':' not in domainToFollow:
|
||||
domainToFollowFull=domainToFollow+':'+str(tempPort)
|
||||
nicknameToFollow=getNicknameFromActor(messageJson['object'])
|
||||
if not nicknameToFollow:
|
||||
if debug:
|
||||
|
@ -466,14 +472,18 @@ def sendFollowRequest(session,baseDir: str, \
|
|||
return None
|
||||
|
||||
fullDomain=domain
|
||||
followActor=httpPrefix+'://'+domain+'/users/'+nickname
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
followActor=httpPrefix+'://'+domain+':'+str(port)+'/users/'+nickname
|
||||
followActor=httpPrefix+'://'+domain+'/users/'+nickname
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
followActor=httpPrefix+'://'+domain+':'+str(port)+'/users/'+nickname
|
||||
|
||||
requestDomain=followDomain
|
||||
if followPort!=80 and followPort!=443:
|
||||
requestDomain=followDomain+':'+str(followPort)
|
||||
if followPort:
|
||||
if followPort!=80 and followPort!=443:
|
||||
if ':' not in followDomain:
|
||||
requestDomain=followDomain+':'+str(followPort)
|
||||
|
||||
statusNumber,published = getStatusNumber()
|
||||
|
||||
|
@ -511,12 +521,16 @@ def sendFollowRequestViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
if fromPort:
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
|
||||
followDomainFull=followDomain
|
||||
if followPort!=80 and followPort!=443:
|
||||
followDomainFull=followDomain+':'+str(followPort)
|
||||
if followPort:
|
||||
if followPort!=80 and followPort!=443:
|
||||
if ':' not in followDomain:
|
||||
followDomainFull=followDomain+':'+str(followPort)
|
||||
|
||||
followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
|
||||
followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
|
||||
|
@ -587,11 +601,15 @@ def sendUnfollowRequestViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
if fromPort:
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
followDomainFull=followDomain
|
||||
if followPort!=80 and followPort!=443:
|
||||
followDomainFull=followDomain+':'+str(followPort)
|
||||
if followPort:
|
||||
if followPort!=80 and followPort!=443:
|
||||
if ':' not in followDomain:
|
||||
followDomainFull=followDomain+':'+str(followPort)
|
||||
|
||||
followActor=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname
|
||||
followedId=httpPrefix+'://'+followDomainFull+'/users/'+followNickname
|
||||
|
@ -745,14 +763,16 @@ def outboxUndoFollow(baseDir: str,messageJson: {},debug: bool) -> None:
|
|||
domainFollowerFull=domainFollower
|
||||
if portFollower:
|
||||
if portFollower!=80 and portFollower!=443:
|
||||
domainFollowerFull=domainFollower+':'+str(portFollower)
|
||||
if ':' not in domainFollower:
|
||||
domainFollowerFull=domainFollower+':'+str(portFollower)
|
||||
|
||||
nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
|
||||
domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object'])
|
||||
domainFollowingFull=domainFollowing
|
||||
if portFollowing:
|
||||
if portFollowing!=80 and portFollowing!=443:
|
||||
domainFollowingFull=domainFollowing+':'+str(portFollowing)
|
||||
if ':' not in domainFollowing:
|
||||
domainFollowingFull=domainFollowing+':'+str(portFollowing)
|
||||
|
||||
if unfollowPerson(baseDir,nicknameFollower,domainFollowerFull, \
|
||||
nicknameFollowing,domainFollowingFull):
|
||||
|
|
18
inbox.py
18
inbox.py
|
@ -187,7 +187,8 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str
|
|||
return None
|
||||
if postPort:
|
||||
if postPort!=80 and postPort!=443:
|
||||
postDomain=postDomain+':'+str(postPort)
|
||||
if ':' not in postDomain:
|
||||
postDomain=postDomain+':'+str(postPort)
|
||||
|
||||
if postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], dict):
|
||||
|
@ -368,8 +369,10 @@ def inboxPostRecipients(baseDir :str,postJsonObject :{},httpPrefix :str,domain :
|
|||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
domainBase=domain
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
domainMatch='/'+domain+'/users/'
|
||||
|
||||
actor = postJsonObject['actor']
|
||||
|
@ -485,14 +488,16 @@ def receiveUndoFollow(session,baseDir: str,httpPrefix: str, \
|
|||
domainFollowerFull=domainFollower
|
||||
if portFollower:
|
||||
if portFollower!=80 and portFollower!=443:
|
||||
domainFollowerFull=domainFollower+':'+str(portFollower)
|
||||
if ':' not in domainFollower:
|
||||
domainFollowerFull=domainFollower+':'+str(portFollower)
|
||||
|
||||
nicknameFollowing=getNicknameFromActor(messageJson['object']['object'])
|
||||
domainFollowing,portFollowing=getDomainFromActor(messageJson['object']['object'])
|
||||
domainFollowingFull=domainFollowing
|
||||
if portFollowing:
|
||||
if portFollowing!=80 and portFollowing!=443:
|
||||
domainFollowingFull=domainFollowing+':'+str(portFollowing)
|
||||
if ':' not in domainFollowing:
|
||||
domainFollowingFull=domainFollowing+':'+str(portFollowing)
|
||||
|
||||
if unfollowerOfPerson(baseDir, \
|
||||
nicknameFollowing,domainFollowingFull, \
|
||||
|
@ -719,7 +724,8 @@ def receiveDelete(session,handle: str,baseDir: str, \
|
|||
domainFull=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
deletePrefix=httpPrefix+'://'+domainFull+'/'
|
||||
if not allowDeletion and \
|
||||
(not messageJson['object'].startswith(deletePrefix) or \
|
||||
|
|
57
like.py
57
like.py
|
@ -137,9 +137,10 @@ def like(session,baseDir: str,federationList: [],nickname: str,domain: str,port:
|
|||
return None
|
||||
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
likeTo=[]
|
||||
if '/statuses/' in objectUrl:
|
||||
|
@ -196,18 +197,20 @@ def likePost(session,baseDir: str,federationList: [], \
|
|||
"""Likes a given status post
|
||||
"""
|
||||
likeDomain=likeDomain
|
||||
if likePort!=80 and likePort!=443:
|
||||
if ':' not in likeDomain:
|
||||
likeDomain=likeDomain+':'+str(likePort)
|
||||
if likePort:
|
||||
if likePort!=80 and likePort!=443:
|
||||
if ':' not in likeDomain:
|
||||
likeDomain=likeDomain+':'+str(likePort)
|
||||
|
||||
objectUrl = \
|
||||
httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \
|
||||
'/statuses/'+str(likeStatusNumber)
|
||||
|
||||
if likePort!=80 and likePort!=443:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
|
||||
else:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
|
||||
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
|
||||
if likePort:
|
||||
if likePort!=80 and likePort!=443:
|
||||
if ':' not in likeDomain:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
|
||||
|
||||
return like(session,baseDir,federationList,nickname,domain,port, \
|
||||
ccList,httpPrefix,objectUrl,clientToServer, \
|
||||
|
@ -227,9 +230,10 @@ def undolike(session,baseDir: str,federationList: [],nickname: str,domain: str,p
|
|||
return None
|
||||
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
likeTo=[]
|
||||
if '/statuses/' in objectUrl:
|
||||
|
@ -291,17 +295,20 @@ def undoLikePost(session,baseDir: str,federationList: [], \
|
|||
"""Removes a liked post
|
||||
"""
|
||||
likeDomain=likeDomain
|
||||
if likePort!=80 and likePort!=443:
|
||||
likeDomain=likeDomain+':'+str(likePort)
|
||||
if likePort:
|
||||
if likePort!=80 and likePort!=443:
|
||||
if ':' not in likeDomain:
|
||||
likeDomain=likeDomain+':'+str(likePort)
|
||||
|
||||
objectUrl = \
|
||||
httpPrefix + '://'+likeDomain+'/users/'+likeNickname+ \
|
||||
'/statuses/'+str(likeStatusNumber)
|
||||
|
||||
if likePort!=80 and likePort!=443:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
|
||||
else:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
|
||||
ccUrl=httpPrefix+'://'+likeDomain+'/users/'+likeNickname
|
||||
if likePort:
|
||||
if likePort!=80 and likePort!=443:
|
||||
if ':' not in likeDomain:
|
||||
ccUrl=httpPrefix+'://'+likeDomain+':'+str(likePort)+'/users/'+likeNickname
|
||||
|
||||
return undoLike(session,baseDir,federationList,nickname,domain,port, \
|
||||
ccList,httpPrefix,objectUrl,clientToServer, \
|
||||
|
@ -319,8 +326,10 @@ def sendLikeViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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']
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
@ -391,8 +400,10 @@ def sendUndoLikeViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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']
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
|
7
media.py
7
media.py
|
@ -67,9 +67,10 @@ def attachImage(baseDir: str,httpPrefix: str,domain: str,port: int, \
|
|||
mediaType='image/gif'
|
||||
fileExtension='gif'
|
||||
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
mPath=getMediaPath()
|
||||
mediaPath=mPath+'/'+createPassword(32)+'.'+fileExtension
|
||||
|
|
18
person.py
18
person.py
|
@ -56,8 +56,10 @@ def setProfileImage(baseDir: str,httpPrefix :str,nickname: str,domain: str, \
|
|||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
fullDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
handle=nickname.lower()+'@'+domain.lower()
|
||||
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)
|
||||
|
||||
handle=nickname.lower()+'@'+domain.lower()
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
newPerson = {'@context': ['https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
|
@ -545,7 +549,8 @@ def canRemovePost(baseDir: str,nickname: str,domain: str,port: int,postId: str)
|
|||
domainFull=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
|
||||
# is the post by the admin?
|
||||
adminNickname=getConfigParam(baseDir,'admin')
|
||||
|
@ -570,7 +575,8 @@ def removeTagsForNickname(baseDir: str,nickname: str,domain: str,port: int) -> N
|
|||
domainFull=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
matchStr=domainFull+'/users/'+nickname+'/'
|
||||
directory = os.fsencode(baseDir+'/tags/')
|
||||
for f in os.listdir(directory):
|
||||
|
|
91
posts.py
91
posts.py
|
@ -431,9 +431,10 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \
|
|||
tags=[]
|
||||
hashtagsDict={}
|
||||
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
# convert content to html
|
||||
content= \
|
||||
|
@ -604,9 +605,10 @@ def outboxMessageCreateWrap(httpPrefix: str, \
|
|||
https://www.w3.org/TR/activitypub/#object-without-create
|
||||
"""
|
||||
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
statusNumber,published = getStatusNumber()
|
||||
if messageJson.get('published'):
|
||||
published = messageJson['published']
|
||||
|
@ -638,8 +640,10 @@ def postIsAddressedToFollowers(baseDir: str,
|
|||
postJsonObject: {}) -> bool:
|
||||
"""Returns true if the given post is addressed to followers of the nickname
|
||||
"""
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
if not postJsonObject.get('object'):
|
||||
return False
|
||||
|
@ -699,9 +703,10 @@ def createPublicPost(baseDir: str,
|
|||
"""Public post
|
||||
"""
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
return createPostBase(baseDir,nickname, domain, port, \
|
||||
'https://www.w3.org/ns/activitystreams#Public', \
|
||||
httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
|
||||
|
@ -719,9 +724,10 @@ def createUnlistedPost(baseDir: str,
|
|||
"""Unlisted post. This has the #Public and followers links inverted.
|
||||
"""
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
return createPostBase(baseDir,nickname, domain, port, \
|
||||
httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
|
||||
'https://www.w3.org/ns/activitystreams#Public', \
|
||||
|
@ -739,9 +745,10 @@ def createFollowersOnlyPost(baseDir: str,
|
|||
"""Followers only post
|
||||
"""
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
return createPostBase(baseDir,nickname, domain, port, \
|
||||
httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers', \
|
||||
None,
|
||||
|
@ -810,7 +817,8 @@ def createReportPost(baseDir: str,
|
|||
domainFull=domain
|
||||
if port:
|
||||
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
|
||||
reportTitle='Moderation Report'
|
||||
|
@ -917,9 +925,10 @@ def sendPost(projectVersion: str, \
|
|||
"""
|
||||
withDigest=True
|
||||
|
||||
if toPort!=80 and toPort!=443:
|
||||
if ':' not in toDomain:
|
||||
toDomain=toDomain+':'+str(toPort)
|
||||
if toPort:
|
||||
if toPort!=80 and toPort!=443:
|
||||
if ':' not in toDomain:
|
||||
toDomain=toDomain+':'+str(toPort)
|
||||
|
||||
handle=httpPrefix+'://'+toDomain+'/@'+toNickname
|
||||
|
||||
|
@ -1010,9 +1019,10 @@ def sendPostViaServer(projectVersion: str, \
|
|||
return 6
|
||||
withDigest=True
|
||||
|
||||
if toPort!=80 and toPort!=443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomain=fromDomain+':'+str(fromPort)
|
||||
if toPort:
|
||||
if toPort!=80 and toPort!=443:
|
||||
if ':' not in fromDomain:
|
||||
fromDomain=fromDomain+':'+str(fromPort)
|
||||
|
||||
handle=httpPrefix+'://'+fromDomain+'/@'+fromNickname
|
||||
|
||||
|
@ -1049,7 +1059,8 @@ def sendPostViaServer(projectVersion: str, \
|
|||
fromDomainFull=fromDomain
|
||||
if fromPort:
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
if ':' not in fromDomain:
|
||||
fromDomainFull=fromDomain+':'+str(fromPort)
|
||||
cc=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
else:
|
||||
if toDomain.lower().endswith('followers') or \
|
||||
|
@ -1057,8 +1068,10 @@ def sendPostViaServer(projectVersion: str, \
|
|||
toPersonId=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
else:
|
||||
toDomainFull=toDomain
|
||||
if toPort!=80 and toDomain!=443:
|
||||
toDomainFull=toDomain+':'+str(toPort)
|
||||
if toPort:
|
||||
if toPort!=80 and toPort!=443:
|
||||
if ':' not in toDomain:
|
||||
toDomainFull=toDomain+':'+str(toPort)
|
||||
toPersonId=httpPrefix+'://'+toDomainFull+'/users/'+toNickname
|
||||
postJsonObject = \
|
||||
createPostBase(baseDir, \
|
||||
|
@ -1273,11 +1286,13 @@ def sendToNamedAddresses(session,baseDir: str, \
|
|||
domainFull=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
toDomainFull=toDomain
|
||||
if toPort:
|
||||
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)
|
||||
cc=[]
|
||||
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')
|
||||
boxname='moderation'
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain = domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
if not pageNumber:
|
||||
pageNumber=1
|
||||
|
@ -1433,8 +1450,10 @@ def createBoxBase(baseDir: str,boxname: str, \
|
|||
if boxname=='inbox':
|
||||
sharedBoxDir = createPersonDir('inbox',domain,baseDir,boxname)
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain = domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
pageStr='?page=true'
|
||||
if pageNumber:
|
||||
|
@ -1660,8 +1679,10 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \
|
|||
federationList=[]
|
||||
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
handle=httpPrefix+"://"+domainFull+"/@"+nickname
|
||||
wfRequest = \
|
||||
webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
||||
|
|
9
roles.py
9
roles.py
|
@ -183,7 +183,8 @@ def outboxDelegate(baseDir: str,authenticatedNickname: str,messageJson: {},debug
|
|||
domainFull=domain
|
||||
if port:
|
||||
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()
|
||||
|
||||
if not role:
|
||||
|
@ -216,8 +217,10 @@ def sendRoleViaServer(session,delegatorNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
delegatorDomainFull=delegatorDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
delegatorDomainFull=delegatorDomain+':'+str(fromPort)
|
||||
if fromPort:
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
if ':' not in delegatorDomain:
|
||||
delegatorDomainFull=delegatorDomain+':'+str(fromPort)
|
||||
|
||||
toUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+nickname
|
||||
ccUrl = httpPrefix+'://'+delegatorDomainFull+'/users/'+delegatorNickname+'/followers'
|
||||
|
|
24
shares.py
24
shares.py
|
@ -101,8 +101,10 @@ def addShare(baseDir: str, \
|
|||
if imageFilename:
|
||||
if os.path.isfile(imageFilename):
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
if not os.path.isdir(baseDir+'/sharefiles'):
|
||||
os.mkdir(baseDir+'/sharefiles')
|
||||
if not os.path.isdir(baseDir+'/sharefiles/'+nickname):
|
||||
|
@ -203,8 +205,10 @@ def getSharesFeedForPerson(baseDir: str, \
|
|||
if not validNickname(nickname):
|
||||
return None
|
||||
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
handleDomain=domain
|
||||
if ':' in handleDomain:
|
||||
|
@ -283,8 +287,10 @@ def sendShareViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
@ -370,8 +376,10 @@ def sendUndoShareViaServer(session,fromNickname: str,password: str,
|
|||
return 6
|
||||
|
||||
fromDomainFull=fromDomain
|
||||
if fromPort!=80 and fromPort!=443:
|
||||
fromDomainFull=fromDomain+':'+str(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'
|
||||
ccUrl = httpPrefix + '://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
||||
|
|
|
@ -98,8 +98,10 @@ def sendSkillViaServer(session,nickname: str,password: str,
|
|||
return 6
|
||||
|
||||
domainFull=domain
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
|
||||
toUrl = httpPrefix+'://'+domainFull+'/users/'+nickname
|
||||
ccUrl = httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers'
|
||||
|
|
6
tests.py
6
tests.py
|
@ -88,8 +88,10 @@ def testHttpsigBase(withDigest):
|
|||
messageBodyJsonStr=json.dumps(messageBodyJson)
|
||||
|
||||
headersDomain=domain
|
||||
if port!=80 and port !=443:
|
||||
headersDomain=domain+':'+str(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())
|
||||
boxpath='/inbox'
|
||||
|
|
7
utils.py
7
utils.py
|
@ -156,9 +156,10 @@ def removeAttachment(baseDir: str,httpPrefix: str,domain: str,postJson: {}):
|
|||
return
|
||||
if not postJson['attachment'][0].get('url'):
|
||||
return
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
attachmentUrl=postJson['attachment'][0]['url']
|
||||
if not attachmentUrl:
|
||||
return
|
||||
|
|
19
webfinger.py
19
webfinger.py
|
@ -79,8 +79,10 @@ def storeWebfingerEndpoint(nickname: str,domain: str,port: int,baseDir: str, \
|
|||
wfJson: {}) -> bool:
|
||||
"""Stores webfinger endpoint for a user to a file
|
||||
"""
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
handle=nickname+'@'+domain
|
||||
wfSubdir='/wfendpoints'
|
||||
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
|
||||
"""
|
||||
originalDomain=domain
|
||||
if port!=80 and port!=443:
|
||||
domain=domain+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
if ':' not in domain:
|
||||
domain=domain+':'+str(port)
|
||||
|
||||
account = {
|
||||
"aliases": [
|
||||
|
@ -178,9 +182,10 @@ def webfingerLookup(path: str,baseDir: str,port: int,debug: bool) -> {}:
|
|||
if debug:
|
||||
print('DEBUG: WEBFINGER no @ in handle '+handle)
|
||||
return None
|
||||
if port!=80 and port !=443:
|
||||
if ':' not in handle:
|
||||
handle=handle+':'+str(port)
|
||||
if port:
|
||||
if port!=80 and port !=443:
|
||||
if ':' not in handle:
|
||||
handle=handle+':'+str(port)
|
||||
filename=baseDir+'/wfendpoints/'+handle.lower()+'.json'
|
||||
if debug:
|
||||
print('DEBUG: WEBFINGER filename '+filename)
|
||||
|
|
|
@ -225,7 +225,8 @@ def htmlEditProfile(baseDir: str,path: str,domain: str,port: int) -> str:
|
|||
domainFull=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
domainFull=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
domainFull=domain+':'+str(port)
|
||||
|
||||
actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json'
|
||||
if not os.path.isfile(actorFilename):
|
||||
|
@ -1013,7 +1014,8 @@ def individualPostAsHtml(baseDir: str, \
|
|||
fullDomain=domain
|
||||
if port:
|
||||
if port!=80 and port!=443:
|
||||
fullDomain=domain+':'+str(port)
|
||||
if ':' not in domain:
|
||||
fullDomain=domain+':'+str(port)
|
||||
|
||||
if fullDomain not in postJsonObject['actor']:
|
||||
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl2,preferredName = \
|
||||
|
@ -1040,7 +1042,8 @@ def individualPostAsHtml(baseDir: str, \
|
|||
actorDomainFull=actorDomain
|
||||
if actorPort:
|
||||
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):
|
||||
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
|
||||
if searchPort:
|
||||
if searchPort!=80 and searchPort!=443:
|
||||
searchDomainFull=searchDomain+':'+str(searchPort)
|
||||
if ':' not in searchDomain:
|
||||
searchDomainFull=searchDomain+':'+str(searchPort)
|
||||
|
||||
profileStr=''
|
||||
with open(baseDir+'/epicyon-profile.css', 'r') as cssFile:
|
||||
|
|
Loading…
Reference in New Issue