mirror of https://gitlab.com/bashrc2/epicyon
Removing actors from follow request file
parent
a0b714cf33
commit
79faa91534
22
follow.py
22
follow.py
|
@ -84,7 +84,7 @@ def _removeFromFollowBase(baseDir: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
acceptOrDenyHandle: str, followFile: str,
|
acceptOrDenyHandle: str, followFile: str,
|
||||||
debug: bool) -> None:
|
debug: bool) -> None:
|
||||||
"""Removes a handle from follow requests or rejects file
|
"""Removes a handle/actor from follow requests or rejects file
|
||||||
"""
|
"""
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
accountsDir = baseDir + '/accounts/' + handle
|
accountsDir = baseDir + '/accounts/' + handle
|
||||||
|
@ -94,8 +94,26 @@ def _removeFromFollowBase(baseDir: str,
|
||||||
print('WARN: Approve follow requests file ' +
|
print('WARN: Approve follow requests file ' +
|
||||||
approveFollowsFilename + ' not found')
|
approveFollowsFilename + ' not found')
|
||||||
return
|
return
|
||||||
|
acceptDenyActor = None
|
||||||
if acceptOrDenyHandle not in open(approveFollowsFilename).read():
|
if acceptOrDenyHandle not in open(approveFollowsFilename).read():
|
||||||
return
|
# is this stored in the file as an actor rather than a handle?
|
||||||
|
acceptDenyNickname = acceptOrDenyHandle.split('@')[0]
|
||||||
|
acceptDenyDomain = acceptOrDenyHandle.split('@')[1]
|
||||||
|
# for each possible users path construct an actor and
|
||||||
|
# check if it exists in teh file
|
||||||
|
usersPaths = ('users', 'profile', 'channel', 'accounts', 'u')
|
||||||
|
actorFound = False
|
||||||
|
for usersName in usersPaths:
|
||||||
|
acceptDenyActor = \
|
||||||
|
'://' + acceptDenyDomain + '/' + \
|
||||||
|
usersName + '/' + acceptDenyNickname
|
||||||
|
if acceptDenyActor in open(approveFollowsFilename).read():
|
||||||
|
# actor found, so use it in the subsequent removal
|
||||||
|
approveHandle = acceptDenyActor
|
||||||
|
actorFound = True
|
||||||
|
break
|
||||||
|
if not actorFound:
|
||||||
|
return
|
||||||
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
approvefilenew = open(approveFollowsFilename + '.new', 'w+')
|
||||||
with open(approveFollowsFilename, 'r') as approvefile:
|
with open(approveFollowsFilename, 'r') as approvefile:
|
||||||
for approveHandle in approvefile:
|
for approveHandle in approvefile:
|
||||||
|
|
Loading…
Reference in New Issue