mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
e8e347199c
commit
f189994879
|
@ -18,14 +18,15 @@ def manualDenyFollowRequest(baseDir: str,nickname: str,domain: str,denyHandle: s
|
||||||
handle=args.nickname+'@'+domain
|
handle=args.nickname+'@'+domain
|
||||||
accountsDir=baseDir+'/accounts/'+handle
|
accountsDir=baseDir+'/accounts/'+handle
|
||||||
approveFollowsFilename=accountsDir+'/followrequests.txt'
|
approveFollowsFilename=accountsDir+'/followrequests.txt'
|
||||||
if handle in open(approveFollowsFilename).read():
|
if handle not in open(approveFollowsFilename).read():
|
||||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
return
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||||
for approveHandle in approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
if not approveHandle.startswith(denyHandle):
|
for approveHandle in approvefile:
|
||||||
approvefilenew.write(approveHandle)
|
if not approveHandle.startswith(denyHandle):
|
||||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
approvefilenew.write(approveHandle)
|
||||||
print('Follow request from '+denyHandle+' was denied.')
|
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||||
|
print('Follow request from '+denyHandle+' was denied.')
|
||||||
|
|
||||||
def manualApproveFollowRequest(session,baseDir: str, \
|
def manualApproveFollowRequest(session,baseDir: str, \
|
||||||
httpPrefix: str,
|
httpPrefix: str,
|
||||||
|
@ -35,39 +36,46 @@ def manualApproveFollowRequest(session,baseDir: str, \
|
||||||
sendThreads: [],postLog: [], \
|
sendThreads: [],postLog: [], \
|
||||||
cachedWebfingers: {},personCache: {}, \
|
cachedWebfingers: {},personCache: {}, \
|
||||||
acceptedCaps: [], \
|
acceptedCaps: [], \
|
||||||
debug: bool):
|
debug: bool) -> None:
|
||||||
"""Manually approve a follow request
|
"""Manually approve a follow request
|
||||||
"""
|
"""
|
||||||
handle=nickname+'@'+domain
|
handle=nickname+'@'+domain
|
||||||
accountsDir=baseDir+'/accounts/'+handle
|
accountsDir=baseDir+'/accounts/'+handle
|
||||||
approveFollowsFilename=accountsDir+'/followrequests.txt'
|
approveFollowsFilename=accountsDir+'/followrequests.txt'
|
||||||
if handle in open(approveFollowsFilename).read():
|
if not os.path.isfile(approveFollowsFilename):
|
||||||
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
if debug:
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
print('WARN: Follow requests file '+approveFollowsFilename+' not found')
|
||||||
for handle in approvefile:
|
return
|
||||||
if handle.startswith(approveHandle):
|
if handle not in open(approveFollowsFilename).read():
|
||||||
if ':' in handle:
|
if debug:
|
||||||
port=int(handle.split(':')[1].replace('\n',''))
|
print(handle+' not in '+approveFollowsFilename)
|
||||||
requestsDir=accountsDir+'/requests'
|
return
|
||||||
followActivityfilename=requestsDir+'/'+handle+'.follow'
|
with open(approveFollowsFilename+'.new', 'w') as approvefilenew:
|
||||||
if os.path.isfile(followActivityfilename):
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
with open(followActivityfilename, 'r') as fp:
|
for handle in approvefile:
|
||||||
followJson=commentjson.load(fp)
|
if handle.startswith(approveHandle):
|
||||||
approveNickname=approveHandle.split('@')[0]
|
if ':' in handle:
|
||||||
approveDomain=approveHandle.split('@')[1].replace('\n','')
|
port=int(handle.split(':')[1].replace('\n',''))
|
||||||
approvePort=port
|
requestsDir=accountsDir+'/requests'
|
||||||
if ':' in approveDomain:
|
followActivityfilename=requestsDir+'/'+handle+'.follow'
|
||||||
approvePort=approveDomain.split(':')[1]
|
if os.path.isfile(followActivityfilename):
|
||||||
approveDomain=approveDomain.split(':')[0]
|
with open(followActivityfilename, 'r') as fp:
|
||||||
followedAccountAccepts(session,baseDir,httpPrefix, \
|
followJson=commentjson.load(fp)
|
||||||
nickname,domain,port, \
|
approveNickname=approveHandle.split('@')[0]
|
||||||
approveNickname,approveDomain,approvePort, \
|
approveDomain=approveHandle.split('@')[1].replace('\n','')
|
||||||
followJson['actor'],federationList, \
|
approvePort=port
|
||||||
followJson,acceptedCaps, \
|
if ':' in approveDomain:
|
||||||
sendThreads,postLog, \
|
approvePort=approveDomain.split(':')[1]
|
||||||
cachedWebfingers,personCache, \
|
approveDomain=approveDomain.split(':')[0]
|
||||||
debug)
|
followedAccountAccepts(session,baseDir,httpPrefix, \
|
||||||
os.remove(followActivityfilename)
|
nickname,domain,port, \
|
||||||
else:
|
approveNickname,approveDomain,approvePort, \
|
||||||
approvefilenew.write(handle)
|
followJson['actor'],federationList, \
|
||||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
followJson,acceptedCaps, \
|
||||||
|
sendThreads,postLog, \
|
||||||
|
cachedWebfingers,personCache, \
|
||||||
|
debug)
|
||||||
|
os.remove(followActivityfilename)
|
||||||
|
else:
|
||||||
|
approvefilenew.write(handle)
|
||||||
|
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||||
|
|
Loading…
Reference in New Issue