forked from indymedia/epicyon
follow request and receive
parent
534cea06f8
commit
4166ce5b70
|
@ -33,8 +33,7 @@ def createAcceptReject(baseDir: str,federationList: [],username: str,domain: str
|
||||||
'actor': prefix+'://'+domain+'/users/'+username,
|
'actor': prefix+'://'+domain+'/users/'+username,
|
||||||
'to': [toUrl],
|
'to': [toUrl],
|
||||||
'cc': [],
|
'cc': [],
|
||||||
'object': objectUrl,
|
'object': objectUrl
|
||||||
'published': published
|
|
||||||
}
|
}
|
||||||
if ccUrl:
|
if ccUrl:
|
||||||
if len(ccUrl)>0:
|
if len(ccUrl)>0:
|
||||||
|
|
31
follow.py
31
follow.py
|
@ -200,6 +200,8 @@ def getFollowingFeed(baseDir: str,domain: str,port: int,path: str,https: bool,fo
|
||||||
return following
|
return following
|
||||||
|
|
||||||
def receiveFollowRequest(baseDir: str,messageJson: {},federationList: []) -> bool:
|
def receiveFollowRequest(baseDir: str,messageJson: {},federationList: []) -> bool:
|
||||||
|
"""Receives a follow request within the POST section of HTTPServer
|
||||||
|
"""
|
||||||
if not messageJson['type'].startswith('Follow'):
|
if not messageJson['type'].startswith('Follow'):
|
||||||
return False
|
return False
|
||||||
if '/users/' not in messageJson['actor']:
|
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):
|
if not os.path.isdir(baseDir+'/accounts/'+handleToFollow):
|
||||||
return False
|
return False
|
||||||
return followerOfPerson(baseDir,username,domain,usernameToFollow,domainToFollow,federationList)
|
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
|
||||||
|
|
3
like.py
3
like.py
|
@ -31,8 +31,7 @@ def like(baseDir: str,federationList: [],username: str,domain: str,port: int,toU
|
||||||
'actor': prefix+'://'+domain+'/users/'+username,
|
'actor': prefix+'://'+domain+'/users/'+username,
|
||||||
'object': objectUrl,
|
'object': objectUrl,
|
||||||
'to': [toUrl],
|
'to': [toUrl],
|
||||||
'cc': [],
|
'cc': []
|
||||||
'published': published
|
|
||||||
}
|
}
|
||||||
if ccUrl:
|
if ccUrl:
|
||||||
if len(ccUrl)>0:
|
if len(ccUrl)>0:
|
||||||
|
|
Loading…
Reference in New Issue