diff --git a/acceptreject.py b/acceptreject.py index 596e72508..7fdaaa4ba 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -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: diff --git a/follow.py b/follow.py index 44aa6b8d5..fe9fba48a 100644 --- a/follow.py +++ b/follow.py @@ -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 diff --git a/like.py b/like.py index 625acb848..0d276f234 100644 --- a/like.py +++ b/like.py @@ -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: