From 4e0120929c4a40d10691af0e44758101ec677ed1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 31 Aug 2019 16:17:07 +0100 Subject: [PATCH] Misleading method name --- follow.py | 16 ++++++++++++++-- inbox.py | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/follow.py b/follow.py index 9ba71c11..dc1ae55a 100644 --- a/follow.py +++ b/follow.py @@ -85,6 +85,17 @@ def followerOfPerson(baseDir: str,nickname: str, domain: str, \ followerNickname,followerDomain, \ federationList,debug,'followers.txt') +def isfollowerOfPerson(baseDir: str,nickname: str, domain: str, \ + followerNickname: str, followerDomain: str) -> bool: + """is the given nickname a follower of followerNickname? + """ + if ':' in domain: + domain=domain.split(':')[0] + followersFile=baseDir+'/accounts/'+nickname+'@'+domain+'/followers.txt' + if not os.path.isfile(followersFile): + return False + return followerNickname+'@'+followerDomain in open(followersFile).read() + def unfollowPerson(baseDir: str,nickname: str, domain: str, \ followNickname: str, followDomain: str, \ followFile='following.txt', \ @@ -410,8 +421,9 @@ def receiveFollowRequest(session,baseDir: str,httpPrefix: str, \ baseDir+'/accounts/'+handleToFollow) return True - if not followerOfPerson(baseDir,nicknameToFollow,domainToFollowFull, \ - nickname,domainFull,federationList,debug): + if not isFollowerOfPerson(baseDir, \ + nicknameToFollow,domainToFollowFull, \ + nickname,domainFull): if debug: print('DEBUG: '+nickname+'@'+domain+ \ ' is already a follower of '+ \ diff --git a/inbox.py b/inbox.py index 8d8e60f7..2fef6033 100644 --- a/inbox.py +++ b/inbox.py @@ -1315,10 +1315,10 @@ def runInboxQueue(projectVersion: str, \ federationList, \ debug,projectVersion, \ acceptedCaps=["inbox:write","objects:read"]): - if debug: - print('DEBUG: Follow accepted from '+keyId) os.remove(queueFilename) queue.pop(0) + if debug: + print('DEBUG: Follow activity for '+keyId+' removed from accepted from queue') continue else: if debug: