diff --git a/follow.py b/follow.py index 31509499e..3d715ffa2 100644 --- a/follow.py +++ b/follow.py @@ -436,6 +436,13 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ # what is the followers policy? if followApprovalRequired(baseDir,nicknameToFollow, \ domainToFollow,debug): + rejectedFollowsFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/followrejects.txt' + if os.path.isfile(rejectedFollowsFilename): + denyHandle=nicknameToFollow+'@'+domainToFollowFull + if denyHandle in open(rejectedFollowsFilename).read(): + print(denyHandle+' was already denied as a follower of '+nickname) + return True + print('Storing follow request for approval') return storeFollowRequest(baseDir, \ nicknameToFollow,domainToFollow,port, \ diff --git a/manualapprove.py b/manualapprove.py index 9334fd354..03b5dcdd1 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -17,6 +17,14 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s """ handle=nickname+'@'+domain accountsDir=baseDir+'/accounts/'+handle + + # has this handle already been rejected? + rejectedFollowsFilename=accountsDir+'/followrejects.txt' + if os.path.isfile(rejectedFollowsFilename): + if denyHandle in open(rejectedFollowsFilename).read(): + print(denyHandle+' has already been rejected as a follower of '+nickname) + return + approveFollowsFilename=accountsDir+'/followrequests.txt' if not os.path.isfile(approveFollowsFilename): if debug: @@ -31,6 +39,12 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s approvefilenew.write(approveHandle) approvefilenew.close() os.rename(approveFollowsFilename+'.new',approveFollowsFilename) + + # Store rejected follows + rejectsFile=open(rejectedFollowsFilename, "a+") + rejectsFile.write(denyHandle+'\n') + rejectsFile.close() + print('Follow request from '+denyHandle+' was denied.') def manualApproveFollowRequest(session,baseDir: str, \