From c49eee530d2faff6ebb58f519beac25443e5a26f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 20 Jul 2019 09:33:18 +0100 Subject: [PATCH] Separate follow accept function --- acceptreject.py | 3 +++ follow.py | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/acceptreject.py b/acceptreject.py index 93a373f0b..04a5f4779 100644 --- a/acceptreject.py +++ b/acceptreject.py @@ -74,6 +74,8 @@ def createReject(baseDir: str,federationList: [], \ def acceptFollow(baseDir: str,domain : str,messageJson: {}, \ federationList: [],debug : bool) -> None: + """Receiving a follow Accept activity + """ if not messageJson.get('object'): return if not messageJson['object'].get('type'): @@ -186,6 +188,7 @@ def receiveAcceptReject(session,baseDir: str, \ print('DEBUG: '+messageJson['type']+' does not contain a nickname') return False handle=nickname.lower()+'@'+domain.lower() + # receive follow accept acceptFollow(baseDir,domain,messageJson,federationList,debug) if debug: print('DEBUG: Uh, '+messageJson['type']+', I guess') diff --git a/follow.py b/follow.py index 06bec9a4a..681abb76f 100644 --- a/follow.py +++ b/follow.py @@ -353,15 +353,33 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ fp.write(approveHandle+'\n') return True return False + followedAccountAccepts(session,baseDir,httpPrefix, \ + nicknameToFollow,domainToFollow,port, \ + nickname,domain,fromPort, \ + messageJson['actor'],federationList, + messageJson,acceptedCaps, \ + sendThreads,postLog, \ + cachedWebfingers,personCache, \ + debug) +def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \ + nicknameToFollow: str,domainToFollow: str,port: int, \ + nickname: str,domain: str,fromPort: int, \ + personUrl: str,federationList: [], \ + followJson: {},acceptedCaps: [], \ + sendThreads: [],postLog: [], \ + cachedWebfingers: {},personCache: {}, \ + debug: bool): + """The person receiving a follow request accepts the new follower + and sends back an Accept activity + """ # send accept back if debug: - print('DEBUG: sending Accept for follow request which arrived at '+ \ + print('DEBUG: sending Accept activity for follow request which arrived at '+ \ nicknameToFollow+'@'+domainToFollow+' back to '+nickname+'@'+domain) - personUrl=messageJson['actor'] acceptJson=createAccept(baseDir,federationList, \ nicknameToFollow,domainToFollow,port, \ - personUrl,'',httpPrefix,messageJson,acceptedCaps) + personUrl,'',httpPrefix,followJson,acceptedCaps) if debug: pprint(acceptJson) print('DEBUG: sending follow Accept from '+ \