Inverting the logic makes more sense

merge-requests/8/head
Bob Mottram 2020-10-28 10:02:02 +00:00
parent e365ea4e4c
commit 050b2e14c9
1 changed files with 13 additions and 17 deletions

View File

@ -103,32 +103,28 @@ def manualApproveFollowRequest(session, baseDir: str,
approveFollowsStr = '' approveFollowsStr = ''
with open(approveFollowsFilename, 'r') as fpFollowers: with open(approveFollowsFilename, 'r') as fpFollowers:
approveFollowsStr = fpFollowers.read() approveFollowsStr = fpFollowers.read()
exists = True exists = False
approveHandleFull = approveHandle approveHandleFull = approveHandle
if approveHandle not in approveFollowsStr: if approveHandle in approveFollowsStr:
print('Manual follow accept: ' + approveHandle + exists = True
' not in requests file ' + approveFollowsFilename +
'\n"' + approveFollowsStr.replace('\n', ' ') + '"')
exists = False
elif '@' in approveHandle: elif '@' in approveHandle:
reqNick = approveHandle.split('@')[0] reqNick = approveHandle.split('@')[0]
reqDomain = approveHandle.split('@')[1].strip() reqDomain = approveHandle.split('@')[1].strip()
reqPrefix = httpPrefix + '://' + reqDomain reqPrefix = httpPrefix + '://' + reqDomain
if reqPrefix + '/profile/' + reqNick not in approveFollowsStr: if reqPrefix + '/profile/' + reqNick in approveFollowsStr:
exists = False exists = True
approveHandleFull = reqPrefix + '/profile/' + reqNick approveHandleFull = reqPrefix + '/profile/' + reqNick
elif reqPrefix + '/channel/' + reqNick not in approveFollowsStr: elif reqPrefix + '/channel/' + reqNick in approveFollowsStr:
exists = False exists = True
approveHandleFull = reqPrefix + '/channel/' + reqNick approveHandleFull = reqPrefix + '/channel/' + reqNick
elif reqPrefix + '/accounts/' + reqNick not in approveFollowsStr: elif reqPrefix + '/accounts/' + reqNick in approveFollowsStr:
exists = False exists = True
approveHandleFull = reqPrefix + '/accounts/' + reqNick approveHandleFull = reqPrefix + '/accounts/' + reqNick
if not exists:
print('Manual follow accept: ' + approveHandleFull +
' not in requests file "' +
approveFollowsStr.replace('\n', ' ') +
'" ' + approveFollowsFilename)
if not exists: if not exists:
print('Manual follow accept: ' + approveHandleFull +
' not in requests file "' +
approveFollowsStr.replace('\n', ' ') +
'" ' + approveFollowsFilename)
return return
approvefilenew = open(approveFollowsFilename + '.new', 'w+') approvefilenew = open(approveFollowsFilename + '.new', 'w+')