mirror of https://gitlab.com/bashrc2/epicyon
Manually approving followers
parent
c9a0167d55
commit
d95ebd9439
|
@ -193,36 +193,3 @@ def receiveAcceptReject(session,baseDir: str, \
|
|||
if debug:
|
||||
print('DEBUG: Uh, '+messageJson['type']+', I guess')
|
||||
return True
|
||||
|
||||
def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: str) -> None:
|
||||
"""Manually deny a follow request
|
||||
"""
|
||||
handle=args.nickname+'@'+domain
|
||||
accountsDir=baseDir+'/accounts/'+handle
|
||||
approveFollowsFilename=accountDir+'/followrequests.txt'
|
||||
if handle in open(approveFollowsFilename).read():
|
||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||
with open(approveFollowsFilename, 'r') as approvefile:
|
||||
for approveHandle in approvefile:
|
||||
if not approveHandle.startswith(denyHandle):
|
||||
approvefilenew.write(approveHandle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||
print('Follow request from '+denyHandle+' was denied.')
|
||||
|
||||
def manualApproveFollowRequest(baseDir: str,nickname: str,domain: str,approveHandle: str):
|
||||
"""Manually approve a follow request
|
||||
"""
|
||||
handle=nickname+'@'+domain
|
||||
accountsDir=baseDir+'/accounts/'+handle
|
||||
approveFollowsFilename=accountDir+'/followrequests.txt'
|
||||
if handle in open(approveFollowsFilename).read():
|
||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||
with open(approveFollowsFilename, 'r') as approvefile:
|
||||
for handle in approvefile:
|
||||
if handle.startswith(approveHandle):
|
||||
if ':' in handle:
|
||||
port=int(handle.split(':')[1].replace('\n',''))
|
||||
# TODO approve follow for handle/port
|
||||
else:
|
||||
approvefilenew.write(handle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||
|
|
19
epicyon.py
19
epicyon.py
|
@ -70,8 +70,8 @@ from roles import sendRoleViaServer
|
|||
from skills import sendSkillViaServer
|
||||
from availability import setAvailability
|
||||
from availability import sendAvailabilityViaServer
|
||||
from acceptreject import manualDenyFollowRequest
|
||||
from acceptreject import manualApproveFollowRequest
|
||||
from manualapprove import manualDenyFollowRequest
|
||||
from manualapprove import manualApproveFollowRequest
|
||||
import argparse
|
||||
|
||||
def str2bool(v):
|
||||
|
@ -336,7 +336,20 @@ if args.approve:
|
|||
if '@' not in args.approve:
|
||||
print('syntax: --approve nick@domain')
|
||||
sys.exit()
|
||||
manualApproveFollowRequest(baseDir,args.nickname,domain,args.approve)
|
||||
sendThreads=[]
|
||||
postLog=[]
|
||||
cachedWebfingers={}
|
||||
personCache={}
|
||||
acceptedCaps=[]
|
||||
manualApproveFollowRequest(session,baseDir, \
|
||||
httpPrefix,
|
||||
args.nickname,domain,port, \
|
||||
args.approve, \
|
||||
federationList, \
|
||||
sendThreads,postLog, \
|
||||
cachedWebfingers,personCache, \
|
||||
acceptedCaps, \
|
||||
debug)
|
||||
sys.exit()
|
||||
|
||||
if args.deny:
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
__filename__ = "manualapprove.py"
|
||||
__author__ = "Bob Mottram"
|
||||
__license__ = "AGPL3+"
|
||||
__version__ = "0.0.1"
|
||||
__maintainer__ = "Bob Mottram"
|
||||
__email__ = "bob@freedombone.net"
|
||||
__status__ = "Production"
|
||||
|
||||
import os
|
||||
import json
|
||||
import commentjson
|
||||
|
||||
from follow import followedAccountAccepts
|
||||
|
||||
def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: str) -> None:
|
||||
"""Manually deny a follow request
|
||||
"""
|
||||
handle=args.nickname+'@'+domain
|
||||
accountsDir=baseDir+'/accounts/'+handle
|
||||
approveFollowsFilename=accountDir+'/followrequests.txt'
|
||||
if handle in open(approveFollowsFilename).read():
|
||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||
with open(approveFollowsFilename, 'r') as approvefile:
|
||||
for approveHandle in approvefile:
|
||||
if not approveHandle.startswith(denyHandle):
|
||||
approvefilenew.write(approveHandle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||
print('Follow request from '+denyHandle+' was denied.')
|
||||
|
||||
def manualApproveFollowRequest(session,baseDir: str, \
|
||||
httpPrefix: str,
|
||||
nickname: str,domain: str,port: int, \
|
||||
approveHandle: str, \
|
||||
federationList: [], \
|
||||
sendThreads: [],postLog: [], \
|
||||
cachedWebfingers: {},personCache: {}, \
|
||||
acceptedCaps: [], \
|
||||
debug: bool):
|
||||
"""Manually approve a follow request
|
||||
"""
|
||||
handle=nickname+'@'+domain
|
||||
accountsDir=baseDir+'/accounts/'+handle
|
||||
approveFollowsFilename=accountDir+'/followrequests.txt'
|
||||
if handle in open(approveFollowsFilename).read():
|
||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||
with open(approveFollowsFilename, 'r') as approvefile:
|
||||
for handle in approvefile:
|
||||
if handle.startswith(approveHandle):
|
||||
if ':' in handle:
|
||||
port=int(handle.split(':')[1].replace('\n',''))
|
||||
requestsDir=accountsDir+'/requests'
|
||||
followActivityfilename=requestsDir+'/'+handle+'.follow'
|
||||
if os.path.isfile(followActivityfilename):
|
||||
with open(followActivityfilename, 'r') as fp:
|
||||
followJson=commentjson.load(fp)
|
||||
approveNickname=approveHandle.split('@')[0]
|
||||
approveDomain=approveHandle.split('@')[1].replace('\n','')
|
||||
approvePort=port
|
||||
if ':' in approveDomain:
|
||||
approvePort=approveDomain.split(':')[1]
|
||||
approveDomain=approveDomain.split(':')[0]
|
||||
followedAccountAccepts(session,baseDir,httpPrefix, \
|
||||
nickname,domain,port, \
|
||||
approveNickname,approveDomain,approvePort, \
|
||||
followJson['actor'],federationList, \
|
||||
followJson,acceptedCaps, \
|
||||
sendThreads,postLog, \
|
||||
cachedWebfingers,personCache, \
|
||||
debug)
|
||||
os.remove(followActivityfilename)
|
||||
else:
|
||||
approvefilenew.write(handle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
Loading…
Reference in New Issue