main
Bob Mottram 2020-02-24 20:10:49 +00:00
parent e999879c19
commit 0bfba2a1f6
1 changed files with 10 additions and 13 deletions

View File

@ -879,28 +879,28 @@ class PubServer(BaseHTTPRequestHandler):
print('Test1 '+path+' '+str(userEnding)) print('Test1 '+path+' '+str(userEnding))
if '/' not in userEnding: if '/' not in userEnding:
return None,None return None,None
userEnding=userEnding.split('/') userEnding2=userEnding.split('/')
print('Test2 '+str(userEnding)) nickname=userEnding2[0]
if len(userEnding)!=2: print('Test2 '+str(userEnding2) + ' nickname='+nickname)
if len(userEnding2)!=2:
return None,None return None,None
print('Test3') print('Test3')
if len(userEnding[1])<14: if len(userEnding2[1])<14:
return None,None return None,None
userEnding[1]=userEnding[1].strip() userEnding2[1]=userEnding2[1].strip()
print('Test4 '+str(userEnding[1])) print('Test4 '+str(userEnding2[1]))
if not userEnding[1].isdigit(): if not userEnding2[1].isdigit():
return None,None return None,None
print('Test5') print('Test5')
nickname=userEnding[0]
# check for blog posts # check for blog posts
blogIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/outbox.index' blogIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/outbox.index'
print('Test6 '+blogIndexFilename) print('Test6 '+blogIndexFilename)
if not os.path.isfile(blogIndexFilename): if not os.path.isfile(blogIndexFilename):
return None,None return None,None
print('Test7') print('Test7')
if '#'+userEnding[1]+'.' not in open(blogIndexFilename).read(): if '#'+userEnding2[1]+'.' not in open(blogIndexFilename).read():
return None,None return None,None
messageId=httpPrefix+'://'+domainFull+'/users/'+nickname+'/statuses/'+userEnding[1] messageId=httpPrefix+'://'+domainFull+'/users/'+nickname+'/statuses/'+userEnding2[1]
print('Test8 '+messageId+' '+str(locatePost(baseDir,nickname,domain,messageId))) print('Test8 '+messageId+' '+str(locatePost(baseDir,nickname,domain,messageId)))
return locatePost(baseDir,nickname,domain,messageId),nickname return locatePost(baseDir,nickname,domain,messageId),nickname
@ -944,7 +944,6 @@ class PubServer(BaseHTTPRequestHandler):
print('Test nickname='+str(blogFilename)) print('Test nickname='+str(blogFilename))
if blogFilename and nickname: if blogFilename and nickname:
postJsonObject=loadJson(blogFilename) postJsonObject=loadJson(blogFilename)
print('Test Blog post loaded')
if isBlogPost(postJsonObject): if isBlogPost(postJsonObject):
msg=htmlBlogPost(self.server.baseDir, \ msg=htmlBlogPost(self.server.baseDir, \
self.server.httpPrefix, \ self.server.httpPrefix, \
@ -957,8 +956,6 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie) self._set_headers('text/html',len(msg),cookie)
self._write(msg) self._write(msg)
return return
else:
print("Test No html returned")
else: else:
print("Test This isn't a blog post "+str(postJsonObject)) print("Test This isn't a blog post "+str(postJsonObject))
self._404() self._404()