diff --git a/daemon.py b/daemon.py index bc164aad..cc4dea4a 100644 --- a/daemon.py +++ b/daemon.py @@ -1078,9 +1078,18 @@ class PubServer(BaseHTTPRequestHandler): followerNickname=originPathStr.replace('/users/','') followingHandle=self.path.split('/followdeny=')[1] if '@' in followingHandle: - manualDenyFollowRequest(self.server.baseDir, \ - followerNickname,self.server.domain, \ - followingHandle) + manualDenyFollowRequest(self.server.session, \ + self.server.baseDir, \ + self.server.httpPrefix, \ + followerNickname,self.server.domain,self.server.port, \ + followingHandle, \ + self.server.federationList, \ + self.server.sendThreads, \ + self.server.postLog, \ + self.server.cachedWebfingers, \ + self.server.personCache, \ + self.server.debug, \ + self.server.projectVersion) self._redirect_headers(originPathStr,cookie) self.server.GETbusy=False return diff --git a/epicyon.py b/epicyon.py index 0e6b77a1..2efd856b 100644 --- a/epicyon.py +++ b/epicyon.py @@ -432,6 +432,7 @@ if args.approve: if '@' not in args.approve: print('syntax: --approve nick@domain') sys.exit() + session = createSession(domain,port,useTor) sendThreads=[] postLog=[] cachedWebfingers={} @@ -455,7 +456,19 @@ if args.deny: if '@' not in args.deny: print('syntax: --deny nick@domain') sys.exit() - manualDenyFollowRequest(baseDir,args.nickname,domain,args.deny) + session = createSession(domain,port,useTor) + sendThreads=[] + postLog=[] + cachedWebfingers={} + personCache={} + manualDenyFollowRequest(session,baseDir, \ + httpPrefix, + args.nickname,domain,port, \ + args.deny, \ + federationList, \ + sendThreads,postLog, \ + cachedWebfingers,personCache, \ + debug,__version__) sys.exit() if args.followerspending: diff --git a/follow.py b/follow.py index 911df897..686b608a 100644 --- a/follow.py +++ b/follow.py @@ -20,6 +20,7 @@ from utils import followPerson from posts import sendSignedJson from posts import getPersonBox from acceptreject import createAccept +from acceptreject import createReject from webfinger import webfingerHandle from auth import createBasicAuthHeader from auth import createPassword @@ -510,6 +511,39 @@ def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \ sendThreads,postLog,cachedWebfingers, \ personCache,debug,projectVersion) +def followedAccountRejects(session,baseDir: str,httpPrefix: str, \ + nicknameToFollow: str,domainToFollow: str,port: int, \ + nickname: str,domain: str,fromPort: int, \ + personUrl: str,federationList: [], \ + followJson: {}, \ + sendThreads: [],postLog: [], \ + cachedWebfingers: {},personCache: {}, \ + debug: bool,projectVersion: str): + """The person receiving a follow request rejects the new follower + and sends back a Reject activity + """ + # send reject back + if debug: + print('DEBUG: sending Reject activity for follow request which arrived at '+ \ + nicknameToFollow+'@'+domainToFollow+' back to '+nickname+'@'+domain) + rejectJson=createReject(baseDir,federationList, \ + nicknameToFollow,domainToFollow,port, \ + personUrl,'',httpPrefix,followJson) + if debug: + pprint(rejectJson) + print('DEBUG: sending follow Reject from '+ \ + nicknameToFollow+'@'+domainToFollow+ \ + ' port '+str(port)+' to '+ \ + nickname+'@'+domain+' port '+ str(fromPort)) + clientToServer=False + return sendSignedJson(rejectJson,session,baseDir, \ + nicknameToFollow,domainToFollow,port, \ + nickname,domain,fromPort, '', \ + httpPrefix,True,clientToServer, \ + federationList, \ + sendThreads,postLog,cachedWebfingers, \ + personCache,debug,projectVersion) + def sendFollowRequest(session,baseDir: str, \ nickname: str,domain: str,port: int,httpPrefix: str, \ followNickname: str,followDomain: str, \ diff --git a/manualapprove.py b/manualapprove.py index 03b5dcdd..f8d61040 100644 --- a/manualapprove.py +++ b/manualapprove.py @@ -11,8 +11,17 @@ import json import commentjson from follow import followedAccountAccepts +from follow import followedAccountRejects -def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: str) -> None: +def manualDenyFollowRequest(session,baseDir: str, \ + httpPrefix: str, + nickname: str,domain: str,port: int, \ + denyHandle: str, \ + federationList: [], \ + sendThreads: [],postLog: [], \ + cachedWebfingers: {},personCache: {}, \ + debug: bool, \ + projectVersion: str) -> None: """Manually deny a follow request """ handle=nickname+'@'+domain @@ -44,6 +53,21 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s rejectsFile=open(rejectedFollowsFilename, "a+") rejectsFile.write(denyHandle+'\n') rejectsFile.close() + + denyNickname=denyHandle.split('@')[0] + approveDomain=denyHandle.split('@')[1].replace('\n','') + approvePort=port + if ':' in denyDomain: + denyPort=denyDomain.split(':')[1] + denyDomain=denyDomain.split(':')[0] + followedAccountRejects(session,baseDir,httpPrefix, \ + nickname,domain,port, \ + denyNickname,denyDomain,denyPort, \ + followJson['actor'],federationList, \ + followJson, \ + sendThreads,postLog, \ + cachedWebfingers,personCache, \ + debug,projectVersion) print('Follow request from '+denyHandle+' was denied.')