From 664d087b0111d41d8686e3169e620e93601e7439 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 18 May 2020 11:14:29 +0100 Subject: [PATCH] Tidying --- utils.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/utils.py b/utils.py index 732eafecb..7efec65fb 100644 --- a/utils.py +++ b/utils.py @@ -339,28 +339,20 @@ def locatePost(baseDir: str, nickname: str, domain: str, # if this post in the shared inbox? postUrl = postUrl.replace('/', '#').replace('/activity', '').strip() - boxName = 'inbox' - postFilename = baseDir + '/accounts/' + nickname + '@' + domain + \ - '/' + boxName + '/' + postUrl + '.' + extension - if os.path.isfile(postFilename): - return postFilename - - boxName = 'outbox' - postFilename = baseDir + '/accounts/' + nickname + '@' + domain + \ - '/' + boxName + '/' + postUrl + '.' + extension - if os.path.isfile(postFilename): - return postFilename - - boxName = 'tlblogs' - postFilename = baseDir + '/accounts/' + nickname + '@' + domain + \ - '/' + boxName + '/' + postUrl + '.'+extension - if os.path.isfile(postFilename): - return postFilename + # search boxes + boxes = ('inbox', 'outbox', 'tlblogs') + for boxName in boxes: + postFilename = baseDir + '/accounts/' + nickname + '@' + domain + \ + '/' + boxName + '/' + postUrl + '.' + extension + if os.path.isfile(postFilename): + return postFilename + # is it in the announce cache? postFilename = baseDir + '/cache/announce/' + \ nickname + '/' + postUrl + '.' + extension if os.path.isfile(postFilename): return postFilename + print('WARN: unable to locate ' + nickname + ' ' + postUrl + '.' + extension) return None