forked from indymedia/epicyon
Send reject activity on manual follow reject
parent
5b28e0e4fe
commit
2dbd187031
15
daemon.py
15
daemon.py
|
@ -1078,9 +1078,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
followerNickname=originPathStr.replace('/users/','')
|
followerNickname=originPathStr.replace('/users/','')
|
||||||
followingHandle=self.path.split('/followdeny=')[1]
|
followingHandle=self.path.split('/followdeny=')[1]
|
||||||
if '@' in followingHandle:
|
if '@' in followingHandle:
|
||||||
manualDenyFollowRequest(self.server.baseDir, \
|
manualDenyFollowRequest(self.server.session, \
|
||||||
followerNickname,self.server.domain, \
|
self.server.baseDir, \
|
||||||
followingHandle)
|
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._redirect_headers(originPathStr,cookie)
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
|
|
15
epicyon.py
15
epicyon.py
|
@ -432,6 +432,7 @@ if args.approve:
|
||||||
if '@' not in args.approve:
|
if '@' not in args.approve:
|
||||||
print('syntax: --approve nick@domain')
|
print('syntax: --approve nick@domain')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
session = createSession(domain,port,useTor)
|
||||||
sendThreads=[]
|
sendThreads=[]
|
||||||
postLog=[]
|
postLog=[]
|
||||||
cachedWebfingers={}
|
cachedWebfingers={}
|
||||||
|
@ -455,7 +456,19 @@ if args.deny:
|
||||||
if '@' not in args.deny:
|
if '@' not in args.deny:
|
||||||
print('syntax: --deny nick@domain')
|
print('syntax: --deny nick@domain')
|
||||||
sys.exit()
|
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()
|
sys.exit()
|
||||||
|
|
||||||
if args.followerspending:
|
if args.followerspending:
|
||||||
|
|
34
follow.py
34
follow.py
|
@ -20,6 +20,7 @@ from utils import followPerson
|
||||||
from posts import sendSignedJson
|
from posts import sendSignedJson
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from acceptreject import createAccept
|
from acceptreject import createAccept
|
||||||
|
from acceptreject import createReject
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
from auth import createPassword
|
from auth import createPassword
|
||||||
|
@ -510,6 +511,39 @@ def followedAccountAccepts(session,baseDir: str,httpPrefix: str, \
|
||||||
sendThreads,postLog,cachedWebfingers, \
|
sendThreads,postLog,cachedWebfingers, \
|
||||||
personCache,debug,projectVersion)
|
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, \
|
def sendFollowRequest(session,baseDir: str, \
|
||||||
nickname: str,domain: str,port: int,httpPrefix: str, \
|
nickname: str,domain: str,port: int,httpPrefix: str, \
|
||||||
followNickname: str,followDomain: str, \
|
followNickname: str,followDomain: str, \
|
||||||
|
|
|
@ -11,8 +11,17 @@ import json
|
||||||
import commentjson
|
import commentjson
|
||||||
|
|
||||||
from follow import followedAccountAccepts
|
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
|
"""Manually deny a follow request
|
||||||
"""
|
"""
|
||||||
handle=nickname+'@'+domain
|
handle=nickname+'@'+domain
|
||||||
|
@ -44,6 +53,21 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s
|
||||||
rejectsFile=open(rejectedFollowsFilename, "a+")
|
rejectsFile=open(rejectedFollowsFilename, "a+")
|
||||||
rejectsFile.write(denyHandle+'\n')
|
rejectsFile.write(denyHandle+'\n')
|
||||||
rejectsFile.close()
|
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.')
|
print('Follow request from '+denyHandle+' was denied.')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue