diff --git a/daemon.py b/daemon.py index c258663a9..d1a23d2a0 100644 --- a/daemon.py +++ b/daemon.py @@ -82,7 +82,6 @@ from utils import getNicknameFromActor from utils import getDomainFromActor from manualapprove import manualDenyFollowRequest from manualapprove import manualApproveFollowRequest -from manualapprove import addHandleToApproveFile from announce import createAnnounce from announce import outboxAnnounce from content import addMentions @@ -751,22 +750,18 @@ class PubServer(BaseHTTPRequestHandler): return # send a follow request approval from the web interface - if authorized and '/followapprove=' in self.path: + if authorized and '/followapprove=' in self.path and self.path.startswith('/users/'): originPathStr=self.path.split('/followapprove=')[0] - followerNickname=getNicknameFromActor(originPathStr) - followerDomain,FollowerPort=getDomainFromActor(originPathStr) + followerNickname=originPathStr.replace('/users/','') followingHandle=self.path.split('/followapprove=')[1] if '@' in followingHandle: if not self.server.session: self.server.session= \ createSession(self.server.domain,self.server.port,self.server.useTor) - addHandleToApproveFile(self.server.baseDir, \ - followerNickname,followerDomain, \ - followingHandle) manualApproveFollowRequest(self.server.session, \ self.server.baseDir, \ self.server.httpPrefix, \ - followerNickname,followerDomain,FollowerPort, \ + followerNickname,self.server.domain,self.server.port, \ followingHandle, \ self.server.federationList, \ self.server.sendThreads, \ @@ -780,17 +775,13 @@ class PubServer(BaseHTTPRequestHandler): return # deny a follow request from the web interface - if authorized and '/followdeny=' in self.path: + if authorized and '/followdeny=' in self.path and self.path.startswith('/users/'): originPathStr=self.path.split('/followdeny=')[0] - followerNickname=getNicknameFromActor(originPathStr) - followerDomain,FollowerPort=getDomainFromActor(originPathStr) + followerNickname=originPathStr.replace('/users/','') followingHandle=self.path.split('/followdeny=')[1] if '@' in followingHandle: - addHandleToApproveFile(self.server.baseDir, \ - followerNickname,followerDomain, \ - followingHandle) manualDenyFollowRequest(self.server.baseDir, \ - followerNickname,followerDomain, \ + followerNickname,self.server.domain, \ followingHandle) self._redirect_headers(originPathStr,cookie) self.server.GETbusy=False diff --git a/manualapprove.py b/manualapprove.py index a69a85433..1954e92b2 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -32,24 +32,6 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s approvefilenew.close() os.rename(approveFollowsFilename+'.new',approveFollowsFilename) print('Follow request from '+denyHandle+' was denied.') - -def addHandleToApproveFile(baseDir: str,nickname: str,domain: str,addHandle: str) -> None: - """Adds the given handle to the follow requests for the given account - """ - handle=nickname+'@'+domain - accountsDir=baseDir+'/accounts/'+handle - approveFollowsFilename=accountsDir+'/followrequests.txt' - appendHandle=True - if os.path.isfile(approveFollowsFilename): - if addHandle in open(approveFollowsFilename).read(): - appendHandle=False - approvefilenew = open(approveFollowsFilename+'.add', 'w+') - with open(approveFollowsFilename, 'r') as approvefile: - for handle in approvefile: - approvefilenew.write(handle) - approvefilenew.write(addHandle) - approvefilenew.close() - os.rename(approveFollowsFilename+'.add',approveFollowsFilename) def manualApproveFollowRequest(session,baseDir: str, \ httpPrefix: str,