follow request and receive

master
Bob Mottram 2019-07-02 19:38:51 +01:00
parent 534cea06f8
commit 4166ce5b70
3 changed files with 33 additions and 4 deletions

View File

@ -33,8 +33,7 @@ def createAcceptReject(baseDir: str,federationList: [],username: str,domain: str
'actor': prefix+'://'+domain+'/users/'+username,
'to': [toUrl],
'cc': [],
'object': objectUrl,
'published': published
'object': objectUrl
}
if ccUrl:
if len(ccUrl)>0:

View File

@ -200,6 +200,8 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str,https: bool,fo
return following
def receiveFollowRequest(baseDir: str,messageJson: {},federationList: []) -> bool:
"""Receives a follow request within the POST section of HTTPServer
"""
if not messageJson['type'].startswith('Follow'):
return False
if '/users/' not in messageJson['actor']:
@ -222,3 +224,32 @@ def receiveFollowRequest(baseDir: str,messageJson: {},federationList: []) -> boo
if not os.path.isdir(baseDir+'/accounts/'+handleToFollow):
return False
return followerOfPerson(baseDir,username,domain,usernameToFollow,domainToFollow,federationList)
def sendFollowRequest(baseDir: str,username: str, domain: str, port: int,https: bool,followUsername: str, followDomain: str, followPort: bool,followHttps: bool,federationList: []):
if not domainPermitted(followDomain,federationList):
return None
prefix='https'
if not https:
prefix='http'
followPrefix='https'
if not followHttps:
followPrefix='http'
if port!=80 and port!=443:
domain=domain+':'+str(port)
if followPort!=80 and followPort!=443:
followDomain=followDomain+':'+str(followPort)
newFollow = {
'type': 'Follow',
'actor': prefix+'://'+domain+'/users/'+username,
'object': followPrefix+'://'+followDomain+'/users/'+followUsername,
'to': [toUrl],
'cc': []
}
if ccUrl:
if len(ccUrl)>0:
newFollow['cc']=ccUrl

View File

@ -31,8 +31,7 @@ def like(baseDir: str,federationList: [],username: str,domain: str,port: int,toU
'actor': prefix+'://'+domain+'/users/'+username,
'object': objectUrl,
'to': [toUrl],
'cc': [],
'published': published
'cc': []
}
if ccUrl:
if len(ccUrl)>0: