From c170a8b5c885e2fae44d39af0083cdbc3641eaa6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 26 Feb 2020 10:10:16 +0000 Subject: [PATCH] Search different boxes --- blog.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/blog.py b/blog.py index a94992e53..f58cb76bc 100644 --- a/blog.py +++ b/blog.py @@ -39,11 +39,19 @@ def noOfBlogReplies(baseDir: str,httpPrefix: str,translate: {}, \ return 0 if not postId: return 0 - postFilename= \ - baseDir+'/accounts/'+nickname+'@'+domain+'/tlblogs/'+ \ - postId.replace('/','#')+'.replies' - if not os.path.isfile(postFilename): + + tryPostBox=('tlblogs','inbox','outbox') + boxFound=False + for postBox in tryPostBox: + postFilename= \ + baseDir+'/accounts/'+nickname+'@'+domain+'/'+postBox+'/'+ \ + postId.replace('/','#')+'.replies' + if os.path.isfile(postFilename): + boxFound=True + break + if not boxFound: return 0 + replies=0 with open(postFilename, "r") as f: lines = f.readlines() @@ -67,11 +75,19 @@ def getBlogReplies(baseDir: str,httpPrefix: str,translate: {}, \ return '' if not postId: return '' - postFilename= \ - baseDir+'/accounts/'+nickname+'@'+domain+'/tlblogs/'+ \ - postId.replace('/','#')+'.replies' - if not os.path.isfile(postFilename): + + tryPostBox=('tlblogs','inbox','outbox') + boxFound=False + for postBox in tryPostBox: + postFilename= \ + baseDir+'/accounts/'+nickname+'@'+domain+'/'+postBox+'/'+ \ + postId.replace('/','#')+'.replies' + if os.path.isfile(postFilename): + boxFound=True + break + if not boxFound: return '' + with open(postFilename, "r") as f: lines = f.readlines() repliesStr=''