From d1493585bc768c85d440f46e7679e0c01a63638f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Dec 2019 13:19:51 +0000 Subject: [PATCH] Follow file not strictly required for approval --- follow.py | 26 ++++++++++++++------------ manualapprove.py | 9 +++++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/follow.py b/follow.py index 4936e6bc7..ff1e27a33 100644 --- a/follow.py +++ b/follow.py @@ -525,7 +525,7 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ messageJson,acceptedCaps, \ sendThreads,postLog, \ cachedWebfingers,personCache, \ - debug,projectVersion) + debug,projectVersion,True) def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \ nicknameToFollow: str,domainToFollow: str,port: int, \ @@ -534,7 +534,8 @@ def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \ followJson: {},acceptedCaps: [], \ sendThreads: [],postLog: [], \ cachedWebfingers: {},personCache: {}, \ - debug: bool,projectVersion: str): + debug: bool,projectVersion: str, \ + removeFollowActivity: bool): """The person receiving a follow request accepts the new follower and sends back an Accept activity """ @@ -555,16 +556,17 @@ def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \ acceptHandle+' port '+ str(fromPort)) clientToServer=False - # remove the follow request json - followActivityfilename= \ - baseDir+'/accounts/'+ \ - nicknameToFollow+'@'+domainToFollow+'/requests/'+ \ - nickname+'@'+domain+'.follow' - if os.path.isfile(followActivityfilename): - try: - os.remove(followActivityfilename) - except: - pass + if removeFollowActivity: + # remove the follow request json + followActivityfilename= \ + baseDir+'/accounts/'+ \ + nicknameToFollow+'@'+domainToFollow+'/requests/'+ \ + nickname+'@'+domain+'.follow' + if os.path.isfile(followActivityfilename): + try: + os.remove(followActivityfilename) + except: + pass return sendSignedJson(acceptJson,session,baseDir, \ nicknameToFollow,domainToFollow,port, \ diff --git a/manualapprove.py b/manualapprove.py index 7014d5775..654cae4eb 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -86,6 +86,7 @@ def manualApproveFollowRequest(session,baseDir: str, \ approvefilenew = open(approveFollowsFilename+'.new', 'w+') updateApprovedFollowers=False + followActivityfilename=None with open(approveFollowsFilename, 'r') as approvefile: for handleOfFollowRequester in approvefile: # is this the approved follow? @@ -113,8 +114,8 @@ def manualApproveFollowRequest(session,baseDir: str, \ followJson,acceptedCaps, \ sendThreads,postLog, \ cachedWebfingers,personCache, \ - debug,projectVersion) - updateApprovedFollowers=True + debug,projectVersion,False) + updateApprovedFollowers=True else: # this isn't the approved follow so it will remain # in the requests file @@ -147,5 +148,9 @@ def manualApproveFollowRequest(session,baseDir: str, \ if approveHandle in open(followersFilename).read(): # update the follow requests with the handles not yet approved os.rename(approveFollowsFilename+'.new',approveFollowsFilename) + # remove the .follow file + if followActivityfilename: + if os.path.isfile(followActivityfilename): + os.remove(followActivityfilename) else: os.remove(approveFollowsFilename+'.new')