mirror of https://gitlab.com/bashrc2/epicyon
Move follow approval functions
parent
5cd0390234
commit
c9a0167d55
|
@ -193,3 +193,36 @@ 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)
|
||||
|
|
29
epicyon.py
29
epicyon.py
|
@ -70,6 +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
|
||||
import argparse
|
||||
|
||||
def str2bool(v):
|
||||
|
@ -334,20 +336,7 @@ if args.approve:
|
|||
if '@' not in args.approve:
|
||||
print('syntax: --approve nick@domain')
|
||||
sys.exit()
|
||||
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 approveHandle.startswith(args.approve):
|
||||
if ':' in approveHandle:
|
||||
port=int(approveHandle.split(':')[1].replace('\n',''))
|
||||
# TODO approve follow for handle/port
|
||||
else:
|
||||
approvefilenew.write(approveHandle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||
manualApproveFollowRequest(baseDir,args.nickname,domain,args.approve)
|
||||
sys.exit()
|
||||
|
||||
if args.deny:
|
||||
|
@ -357,17 +346,7 @@ if args.deny:
|
|||
if '@' not in args.deny:
|
||||
print('syntax: --deny nick@domain')
|
||||
sys.exit()
|
||||
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(args.deny):
|
||||
approvefilenew.write(approveHandle)
|
||||
os.rename(approveFollowsFilename+'.new',approveFollowsFilename)
|
||||
print('Follow request from '+args.deny+' was denied.')
|
||||
manualDenyFollowRequest(baseDir,args.nickname,domain,args.deny)
|
||||
sys.exit()
|
||||
|
||||
if args.followerspending:
|
||||
|
|
Loading…
Reference in New Issue